Skip to content

Commit

Permalink
removed prior function (and saved privately). removed last case of si…
Browse files Browse the repository at this point in the history
…gmoid prior in noiselss model. neural and joint tests corrected becuase they use sigmoids (didn't use in elife, or in notebooks)
  • Loading branch information
briandepasquale committed Aug 28, 2024
1 parent 638e309 commit da7f1c4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 70 deletions.
15 changes: 0 additions & 15 deletions src/PulseInputDDM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import StatsFuns: logistic, logit, softplus, xlogy
import Base.rand
import Base.Iterators: partition
import Flatten: flattenable
#import Polynomials: Poly

export choiceDDM, θchoice, θz, choiceoptions
export neuralDDM, θneural, θy, neural_options, neuraldata
Expand Down Expand Up @@ -59,7 +58,6 @@ include("base_model.jl")
include("analysis_functions.jl")
include("optim_funcs.jl")
include("sample_model.jl")
include("priors.jl")

include("choice_model/choice_model.jl")
include("choice_model/sample_model.jl")
Expand All @@ -72,21 +70,8 @@ include("neural_model/process_data.jl")
include("neural_model/noiseless_model.jl")
include("neural_model/RBF_model.jl")

#include("neural_model/neural_model-sep.jl")
#include("neural_model/filter/filtered.jl")
#include("neural_model/neural_model-th.jl")

include("neural-choice_model/neural-choice_model.jl")
include("neural-choice_model/sample_model.jl")
include("neural-choice_model/neural-choice_model-ALT.jl")

#include("neural-choice_model/neural-choice_model-negBin.jl")
#include("neural-choice_model/process_data.jl")

##include("neural_model/null.jl")
##include("neural_model/polynomial/neural_poly_model.jl")
##include("neural_model/polynomial/noiseless_model_poly.jl")
##include("neural_model/load_and_optimize.jl")
##include("neural_model/sample_model_functions_FP.jl")

end
4 changes: 2 additions & 2 deletions src/neural_model/noiseless_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Returns:
function fit(model::noiseless_neuralDDM, data, options::neural_options_noiseless;
x_tol::Float64=1e-10, f_tol::Float64=1e-6, g_tol::Float64=1e-3,
iterations::Int=Int(2e3), show_trace::Bool=false,
outer_iterations::Int=Int(1e1), sig_σ::Float64=1.)
outer_iterations::Int=Int(1e1))

@unpack fit, lb, ub = options
@unpack θ = model
Expand All @@ -103,7 +103,7 @@ function fit(model::noiseless_neuralDDM, data, options::neural_options_noiseless
lb, = unstack(lb, fit)
ub, = unstack(ub, fit)
x0,c = unstack(x0, fit)
ℓℓ(x) = -(loglikelihood(stack(x,c,fit), model, data) + sigmoid_prior(stack(x,c,fit), θ; sig_σ=sig_σ))
ℓℓ(x) = -loglikelihood(stack(x,c,fit), model, data)

output = optimize(x0, ℓℓ, lb, ub; g_tol=g_tol, x_tol=x_tol,
f_tol=f_tol, iterations=iterations, show_trace=show_trace,
Expand Down
44 changes: 0 additions & 44 deletions src/priors.jl

This file was deleted.

8 changes: 4 additions & 4 deletions test/joint_model_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ options = neural_choice_options(f)

choice_neural_model = neural_choiceDDM(θneural_choice(vcat(x0[1:dimz], 0., 0., x0[dimz+1:end]), f), n, cross)

@test round(choice_loglikelihood(choice_neural_model, data), digits=2) -0.47
@test round(choice_loglikelihood(choice_neural_model, data), digits=2) -0.44

@test round(joint_loglikelihood(choice_neural_model, data), digits=2) -368.42
@test round(joint_loglikelihood(choice_neural_model, data), digits=2) -368.03

nparams, = PulseInputDDM.nθparams(f)

options = neural_choice_options(fit=vcat(falses(dimz), trues(2), falses.(nparams)...), lb=options.lb, ub=options.ub)

choice_neural_model, = choice_optimize(choice_neural_model, data, options; iterations=2, outer_iterations=1)

@test round(norm(PulseInputDDM.flatten(choice_neural_model.θ)), digits=2) 56.29
@test round(norm(PulseInputDDM.flatten(choice_neural_model.θ)), digits=2) 55.87

choice_neural_model = neural_choiceDDM(θneural_choice(vcat(x0[1:dimz], 0., 0., x0[dimz+1:end]), f), n, cross)

Expand All @@ -50,4 +50,4 @@ options = neural_choice_options(fit=vcat(trues(dimz), trues(2), trues.(nparams).

choice_neural_model, = choice_optimize(choice_neural_model, data, options; iterations=2, outer_iterations=1)

@test round(norm(PulseInputDDM.flatten(choice_neural_model.θ)), digits=2) 56.29
@test round(norm(PulseInputDDM.flatten(choice_neural_model.θ)), digits=2) 55.87
10 changes: 5 additions & 5 deletions test/neural_model_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ x0 = PulseInputDDM.flatten(θ0)
@test round(loglikelihood(x0, model0, data), digits=2) -1495.92

model, = fit(model0, data, options0; iterations=2, outer_iterations=1)
@test round(norm(PulseInputDDM.flatten(model.θ)), digits=2) 58.68
@test round(norm(PulseInputDDM.flatten(model.θ)), digits=2) 58.28

@test round(norm(gradient(model, data)), digits=2) 260.59
@test round(norm(gradient(model, data)), digits=2) 646.89

x0 = vcat([0.1, 15., -0.1, 20., 0.5, 0.8, 0.008], PulseInputDDM.flatten(model.θ)[dimz+1:end])
options = neural_options(f)

model = neuralDDM(θneural(x0, f), n, cross)
model, = fit(model, data, options; iterations=2, outer_iterations=1)
@test round(norm(PulseInputDDM.flatten(model.θ)), digits=2) 55.93
@test round(norm(PulseInputDDM.flatten(model.θ)), digits=2) 55.53

H = Hessian(model, data; chunk_size=4)
@test round(norm(H), digits=2) 15.52
@test round(norm(H), digits=2) 8.6

CI, HPSD = CIs(H)
@test round(norm(CI), digits=2) 690.51
@test round(norm(CI), digits=2) 1149.39

0 comments on commit da7f1c4

Please sign in to comment.