-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ It has the following Hyperparameters: | |
- `fit_prior_nsteps`: the number of steps used to fit the priors. | ||
""" | ||
MLJBase.@mlj_model mutable struct LaplaceRegressor <: MLJFlux.MLJFluxProbabilistic | ||
flux_model::Flux.Chain= nothing | ||
flux_model::Flux.Chain = nothing | ||
subset_of_weights::Symbol = :all::(_ in (:all, :last_layer, :subnetwork)) | ||
subnetwork_indices = nothing | ||
hessian_structure::Union{HessianStructure,Symbol,String} = | ||
|
@@ -39,23 +39,25 @@ MLJBase.@mlj_model mutable struct LaplaceRegressor <: MLJFlux.MLJFluxProbabilist | |
end | ||
|
||
|
||
function MMI.fit(m::LaplaceRegressor, verbosity, X, y, w=nothing) | ||
function MMI.fit(m::LaplaceRegressor, verbosity, X, y) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pat-alt
Member
|
||
features = Tables.schema(X).names | ||
|
||
X = MLJBase.matrix(X) | ||
|
||
la = LaplaceRedux.Laplace( | ||
m.flux_model; | ||
likelihood=:regression, | ||
subset_of_weights=model.subset_of_weights, | ||
subnetwork_indices=model.subnetwork_indices, | ||
hessian_structure=model.hessian_structure, | ||
backend=model.backend, | ||
subset_of_weights=m.subset_of_weights, | ||
subnetwork_indices=m.subnetwork_indices, | ||
hessian_structure=m.hessian_structure, | ||
backend=m.backend, | ||
σ=m.σ, | ||
μ₀=m.μ₀, | ||
P₀=m.P₀, | ||
) | ||
|
||
println(la) | ||
|
||
# fit the Laplace model: | ||
LaplaceRedux.fit!(la, zip(X, y)) | ||
optimize_prior!(la; verbose=verbose_laplace, n_steps=model.fit_prior_nsteps) | ||
|
@@ -122,7 +124,7 @@ end | |
|
||
|
||
|
||
function MMI.fit(m::LaplaceClassifier, verbosity, X, y, w=nothing) | ||
function MMI.fit(m::LaplaceClassifier, verbosity, X, y) | ||
features = Tables.schema(X).names | ||
Xmatrix = MLJBase.matrix(X) | ||
decode = y[1] | ||
|
@pat-alt @MojiFarmanbar I am having some trouble with the input data format. According to the mlj documentation i must suppose that X is a table so i extract the names of the features and then convert to a matrix but then i have problem when i try to fit the laplace object.