We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Right now have to manually clone all the weights, bug prone
The text was updated successfully, but these errors were encountered:
What code did you use for cloning?
Sorry, something went wrong.
@mratsim Like this:
intoBrain.gru.w3s0 = ctx.variable(fromBrain.gru.w3s0.value.clone()) intoBrain.gru.w3sN = ctx.variable(fromBrain.gru.w3sN.value.clone()) intoBrain.gru.u3s = ctx.variable(fromBrain.gru.u3s.value.clone()) intoBrain.gru.bW3s = ctx.variable(fromBrain.gru.bW3s.value.clone()) intoBrain.gru.bU3s = ctx.variable(fromBrain.gru.bU3s.value.clone()) intoBrain.fc1.weight = ctx.variable(fromBrain.fc1.weight.value.clone()) intoBrain.fc1.bias = ctx.variable(fromBrain.fc1.bias.value.clone()) intoBrain.fc2.weight = ctx.variable(fromBrain.fc2.weight.value.clone()) intoBrain.fc2.bias = ctx.variable(fromBrain.fc2.bias.value.clone())
Where the brain is like this:
CreatureBrain[T] = object gru: GRULayer[T] memory: Variable[Tensor[T]] fc1: Linear[T] fc2: Linear[T]
As a workaround in the meantime, you can use fields iterator here: https://nim-lang.org/docs/iterators.html#fields.i%2CS%2CT
proc copyWeights[T](intoBrain: var T, fromBrain: T) = for dst, src in fields(intoBrain, fromBrain): when dst is Variable: dst = ctx.variable(src.value.clone()) else: dst.copyWeights(src)
No branches or pull requests
Right now have to manually clone all the weights, bug prone
The text was updated successfully, but these errors were encountered: