I want to replicate Python code in Julia but I get an error.
#Neural network construction
using Flux, Plots
model = Chain(Dense(5 => 32), Dense(32 => 32), Dense(32 => 2, bias=false))
function dr(a::Vector, z::Vector, e_r::Vector, R::Vector, C::Vector)
# create two empty vectors of length n
n = length(a)
x = zeros(n)
y = zeros(n)
# we normalize exogenous state variables by their 2 standard deviations # so that they are typically between -1 and 1 a = a/sigma_e_a/2 z = z/sigma_e_z/2 e_r = e_r/sigma_e_r/2 # we normalze interest rate and consumtpion to be between -1 and 1 R = (R-Rmin)/(Rmax-Rmin)*2.0-1.0 C = (C-Cmin)/(Cmax-Cmin)*2.0-1.0 s = cat([_e[:, 1] for _e in [a, z, e_r, R, C]], dims=2) x = model(s) # n x 2 matrix # consumption share is always in [0,1] lambda_desicion = exp.x[:,1] # expectation of marginal consumption is always positive pie_desicion = x[:,2] return (lambda_desicion, pie_desicion)
Rvec = LinRange(Rmin, Rmax, 100)
Cvec = LinRange(cmin, cmax, 100)
Rvec = vcat(Rvec)
Cvec = vcat(Cvec)
lambdavec,pievec = dr(Rvec0, Rvec0, Rvec*0, Rvec, Cvec)
Can anyone, please, tell me what’s wrong with my code?