Skip to content

couple of improvements to MPO #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ReinforcementLearningCore/src/utils/networks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ Transform a vector containing the non-zero elements of a lower triangular da x d
function vec_to_tril(cholesky_vec, da)
batch_size = size(cholesky_vec, 3)
c2idx(i, j) = ((2da - j) * (j - 1)) ÷ 2 + i #return the position in cholesky_vec of the element of the triangular matrix at coordinates (i,j)
softplusbeta(x) = log(exp(0.1f0 * x) +1)*10f0 #a softer softplus to avoid vanishing values
function f(j) #return a slice (da x 1 x batchsize) containing the jth columns of the lower triangular cholesky decomposition of the covariance
tc_diag = softplus.(cholesky_vec[c2idx(j, j):c2idx(j, j), :, :])
tc_diag = softplusbeta.(cholesky_vec[c2idx(j, j):c2idx(j, j), :, :]) .+ 1f-5
tc_other = cholesky_vec[c2idx(j, j)+1:c2idx(j + 1, j + 1)-1, :, :]
zs = ignore_derivatives() do
zs = similar(cholesky_vec, da - size(tc_other, 1) - 1, 1, batch_size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ end

function solve_mpodual(Q::AbstractArray, ϵ)
g(η) = η * ϵ + η * mean(logsumexp( Q ./η .- Float32(log(size(Q, 2))), dims = 2))
Optim.minimizer(optimize(g, eps(ϵ), 10f0))
Optim.minimizer(optimize(g, eps(ϵ), maximum(abs.(Q))))
end

#For CovGaussianNetwork
Expand Down