Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

A bit of help with objects and arrays

$
0
0

Hi Everyone

I am yet another new Julia language user and I come from a C/Fortran background. So I am pretty weak with some of the object concepts and advanced array syntax. (I will figure it out). I am primarily interested in Julia to migrate more modern scientific computing platform for research purposes. It has been great but I have a long way to go.

I have a small project to perform differential parameter estimation and I am using this example that fits well.
Great Starting Example

I have my own version and I am getting daunting and lengthy error messages but they seem to be related to my modified ‘loss’ function:

function loss(p)
  sol = solve(prob, Tsit5(), p=p, saveat = tsteps)
  loss = 0.0
  for i in eachindex(tsteps)
      loss += (sol(tsteps[i],idxs=1)-1.0)^2
  end
  #loss = sum(abs2, sol.-1)
  return loss, sol
end

That change to the original example generates the same error message. The top portion of that error is listed here:

ERROR: LoadError: MethodError: no method matching size(::NamedTuple{(:u, :u_analytic, :errors, :t, :k, :prob, :alg, :interp, :dense, :tslocation, :destats, :retcode),Tuple{Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,NamedTuple{(:t, :u),Tuple{Nothing,Array{Array{Float64,1},1}}},Nothing,Nothing,Nothing,Nothing}})

I must be messing up in some way that I don’t understand. I am trying to rewrite the loss function in a way that allows me to customize its value but the above rewrite of the example loss function was my attempt to change it in a way that would give the same result.

Is there anything really obvious that is incorrect with my modified function?

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images