-
Notifications
You must be signed in to change notification settings - Fork 2
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
How to freeze parameters #7
Comments
The mutable struct Foo
x
y
end
mutable struct Bar
foo::Foo
z
end
m = Bar(Foo(1, 2), 3) And you want to ignore Foo's ignore = Set([
(:foo, :x),
(:z,)
])
update!(m, gm, ignore=ignore) Note that this is a low-level and unstable API. I'm currently working on such small things, including this very specific task - freezing the parameters - but I have several uses cases and no specific design yet. I'll be grateful if you describe your use case so that I could make the API more convenient. |
Thank you for the answer. This solution is great. My use case is just the case that you have exposed: to use a pretrained model ( I don't know if there is any possibility to pass only the parameters to calculate the gradients to Yötä, in similar way that JAX done. Thanks. |
Great, pretraining is a very important use case for Avalon, so we will definitely have a more concise syntax for freezing parameters, but exact API will arrive later, perhaps shortly after the high-level training API. Please note that the ignore list expects full field paths, so using just function collect_fields(obj)
paths = []
for p in propertynames(obj)
subpaths = collect_fields(getproperty(obj, p))
if !isempty(subpaths)
for subpath in subpaths
path = [p; subpath...]
push!(paths, path)
end
else
push!(paths, [p])
end
end
return [(path...,) for path in paths]
end
I'm not sure I've got you correctly, but if you are looking for a semantics like: f(x) = ...
gf = grad(f)
gf(x) Unfortunately it's not possible out of the box because without concrete arguments Yota doesn't really know which method of grad_fn(f) = args -> grad(f, args...) Is it what you were asking about? |
Hello,
I would like to know how to freeze parameters in a model, that is, how to training only a subset of parameters.
Thank you.
The text was updated successfully, but these errors were encountered: