Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing model refusing to output any information that is new? #561

Open
Retkid opened this issue Jul 21, 2022 · 1 comment
Open

Importing model refusing to output any information that is new? #561

Retkid opened this issue Jul 21, 2022 · 1 comment

Comments

@Retkid
Copy link

Retkid commented Jul 21, 2022

network TwoLayersNet:
  layers:
    fc1: Linear(300, 42)
    fc2: Linear(42, 300)
  forward x:
    x.fc1.relu.fc2

proc load*(ctx: Context[Tensor[float32]], inny : int): TwoLayersNet[float32] =
  result.fc1.weight = ctx.variable(read_npy[float32](&"model/hiddenweight{inny}.npy"), requires_grad = true)
  result.fc1.bias   = ctx.variable(read_npy[float32](&"model/hiddenbias{inny}.npy"), requires_grad = true)
  result.fc2.weight = ctx.variable(read_npy[float32](&"model/outputweight{inny}.npy"), requires_grad = true)
  result.fc2.bias   = ctx.variable(read_npy[float32](&"model/outputbias{inny}.npy"), requires_grad = true)

proc forward(network: TwoLayersNet, x: Variable): Variable =
  result =  x.linear(
    network.fc1.weight, network.fc1.bias).relu.linear(
      network.fc2.weight, network.fc2.bias)

This is essentially the same code as in the example, saved with the same function shown to me. But yet the output looks a bit like this.

image

I don't really know... what to do or where to go from here.

@Vindaar
Copy link
Collaborator

Vindaar commented Jul 22, 2022

Can you either provide a fully working code example that showcases the issue or given that you said the existing example (https://github.com/mratsim/Arraymancer/blob/master/examples/ex07_save_load_model.nim) doesn't work for you either explain what's wrong with it?

edit: to expand on why that is important: without it I don't know what to tell you. The network you showed there might just be in a training state where that is expected etc. So without having some reproducible code that shows the training & predictions based on the trained network first, then serializes & deserializes and predicts again it's hard to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants