diff --git a/src/pomdp/inference.jl b/src/pomdp/inference.jl index 23503ef..d0bf041 100644 --- a/src/pomdp/inference.jl +++ b/src/pomdp/inference.jl @@ -96,7 +96,7 @@ function fixed_point_iteration(A::Vector{Any}, obs::Vector{Vector{Real}}, num_ob likelihood = spm_log_single(likelihood) # Initialize posterior and prior - qs = Array{Any}(undef, n_factors) + qs = Vector{Vector{Real}}(undef, n_factors) for factor in 1:n_factors qs[factor] = ones(Real,num_states[factor]) / num_states[factor] end @@ -113,7 +113,7 @@ function fixed_point_iteration(A::Vector{Any}, obs::Vector{Vector{Real}}, num_ob # Single factor condition if n_factors == 1 qL = spm_dot(likelihood, qs[1]) - return to_array_of_any(softmax(qL .+ prior[1])) + return [softmax(qL .+ prior[1])] else # Run Iteration curr_iter = 0 diff --git a/src/utils/utils.jl b/src/utils/utils.jl index 5433a60..ea9d4f0 100644 --- a/src/utils/utils.jl +++ b/src/utils/utils.jl @@ -55,19 +55,6 @@ function get_model_dimensions(A = nothing, B = nothing) end -""" Equivalent to pymdp's "to_obj_array" """ -function to_array_of_any(arr::Array) - # Check if arr is already an array of arrays - if typeof(arr) == Array{Array,1} - return arr - end - # Create an array_out and assign squeezed array to the first element - obj_array_out = Array{Any,1}(undef, 1) - obj_array_out[1] = dropdims(arr, dims = tuple(findall(size(arr) .== 1)...)) - return obj_array_out -end - - """ Selects the highest value from Array -- used for deterministic action sampling """ function select_highest(options_array::Array{Float64}) options_with_idx = [(i, option) for (i, option) in enumerate(options_array)]