-
Notifications
You must be signed in to change notification settings - Fork 4
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
fixed issue with MLJFlux.train #113
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,22 +219,6 @@ function MLJFlux.train( | |
) | ||
X = X isa Tables.MatrixTable ? MLJBase.matrix(X) : X | ||
|
||
if !isa(chain, AbstractLaplace) | ||
la = LaplaceRedux.Laplace( | ||
chain; | ||
likelihood=:regression, | ||
subset_of_weights=model.subset_of_weights, | ||
subnetwork_indices=model.subnetwork_indices, | ||
hessian_structure=model.hessian_structure, | ||
backend=model.backend, | ||
σ=model.σ, | ||
μ₀=model.μ₀, | ||
P₀=model.P₀, | ||
) | ||
else | ||
la = chain | ||
end | ||
|
||
# Initialize history: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rockdeldiablo , I would suggest to keep this if-else on top as it was because it checks if chain is abstractlaplace or not. moving this piece down before LaplaceRedux.fit doesn't add any logics. if you agree i would suggest the followings:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MojiFarmanbar honestly i do not think it would work because the laplace object is required only by LaplaceRedux.fit which is at the end. have you tested it? |
||
history = [] | ||
verbose_laplace = false | ||
|
@@ -263,6 +247,22 @@ function MLJFlux.train( | |
push!(history, current_loss) | ||
end | ||
|
||
if !isa(chain, AbstractLaplace) | ||
la = LaplaceRedux.Laplace( | ||
chain; | ||
likelihood=:regression, | ||
subset_of_weights=model.subset_of_weights, | ||
subnetwork_indices=model.subnetwork_indices, | ||
hessian_structure=model.hessian_structure, | ||
backend=model.backend, | ||
σ=model.σ, | ||
μ₀=model.μ₀, | ||
P₀=model.P₀, | ||
) | ||
else | ||
la = chain | ||
end | ||
|
||
# fit the Laplace model: | ||
LaplaceRedux.fit!(la, zip(X, y)) | ||
optimize_prior!(la; verbose=verbose_laplace, n_steps=model.fit_prior_nsteps) | ||
|
@@ -387,22 +387,6 @@ function MLJFlux.train( | |
) | ||
X = X isa Tables.MatrixTable ? MLJBase.matrix(X) : X | ||
|
||
if !isa(chain, AbstractLaplace) | ||
la = LaplaceRedux.Laplace( | ||
chain; | ||
likelihood=:classification, | ||
subset_of_weights=model.subset_of_weights, | ||
subnetwork_indices=model.subnetwork_indices, | ||
hessian_structure=model.hessian_structure, | ||
backend=model.backend, | ||
σ=model.σ, | ||
μ₀=model.μ₀, | ||
P₀=model.P₀, | ||
) | ||
else | ||
la = chain | ||
end | ||
|
||
# Initialize history: | ||
history = [] | ||
verbose_laplace = false | ||
|
@@ -432,6 +416,21 @@ function MLJFlux.train( | |
push!(history, current_loss) | ||
end | ||
|
||
if !isa(chain, AbstractLaplace) | ||
la = LaplaceRedux.Laplace( | ||
chain; | ||
likelihood=:classification, | ||
subset_of_weights=model.subset_of_weights, | ||
subnetwork_indices=model.subnetwork_indices, | ||
hessian_structure=model.hessian_structure, | ||
backend=model.backend, | ||
σ=model.σ, | ||
μ₀=model.μ₀, | ||
P₀=model.P₀, | ||
) | ||
else | ||
la = chain | ||
end | ||
# fit the Laplace model: | ||
LaplaceRedux.fit!(la, zip(X, y)) | ||
optimize_prior!(la; verbose=verbose_laplace, n_steps=model.fit_prior_nsteps) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rockdeldiablo, changing the julia version is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MojiFarmanbar yes it shouldn't be a problem.