Skip to content

Commit 78d5f45

Browse files
committed
rename MLP_3layer to mlp3 for convenience
1 parent f2affe2 commit 78d5f45

File tree

6 files changed

+24
-139
lines changed

6 files changed

+24
-139
lines changed

example/HamiltonianVI/model.jl

Whitespace-only changes.

example/HamiltonianVI/momentum.jl

Lines changed: 0 additions & 80 deletions
This file was deleted.

example/common.jl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Random, Distributions, LinearAlgebra, Bijectors
1+
using Random, Distributions, LinearAlgebra
2+
using Bijectors: transformed
3+
using Flux
4+
5+
"""
6+
A simple wrapper for a 3 layer dense MLP
7+
"""
8+
function mlp3(input_dim::Int, hidden_dims::Int, output_dim::Int; activation=Flux.leakyrelu)
9+
return Chain(
10+
Flux.Dense(input_dim, hidden_dims, activation),
11+
Flux.Dense(hidden_dims, hidden_dims, activation),
12+
Flux.Dense(hidden_dims, output_dim),
13+
)
14+
end
15+
16+
function create_flow(Ls, q₀)
17+
ts = reduce(, Ls)
18+
return transformed(q₀, ts)
19+
end
220

321
function compare_trained_and_untrained_flow(
422
flow_trained::Bijectors.MultivariateTransformed,
@@ -79,10 +97,6 @@ end
7997
# return p
8098
# end
8199

82-
function create_flow(Ls, q₀)
83-
ts = reduce(, Ls)
84-
return transformed(q₀, ts)
85-
end
86100

87101
function visualize(p::Bijectors.MultivariateTransformed, samples=rand(p, 1000))
88102
xrange = range(minimum(samples[1, :]) - 1, maximum(samples[1, :]) + 1; length=100)

example/demo_RealNVP.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function AffineCoupling(
3232
mask_idx::AbstractVector, # index of dimensione that one wants to apply transformations on
3333
)
3434
cdims = length(mask_idx) # dimension of parts used to construct coupling law
35-
s = MLP_3layer(cdims, hdims, cdims)
36-
t = MLP_3layer(cdims, hdims, cdims)
35+
s = mlp3(cdims, hdims, cdims)
36+
t = mlp3(cdims, hdims, cdims)
3737
mask = PartitionMask(dim, mask_idx)
3838
return AffineCoupling(dim, mask, s, t)
3939
end
@@ -99,8 +99,8 @@ end
9999
# mask_idx::AbstractVector, # index of dimensione that one wants to apply transformations on
100100
# )
101101
# cdims = length(mask_idx) # dimension of parts used to construct coupling law
102-
# s = MLP_3layer(cdims, hdims, cdims)
103-
# t = MLP_3layer(cdims, hdims, cdims)
102+
# s = mlp3(cdims, hdims, cdims)
103+
# t = mlp3(cdims, hdims, cdims)
104104
# mask = PartitionMask(dim, mask_idx)
105105
# return AffineCoupling(dim, mask, s, t)
106106
# end

example/demo_neural_spline_flow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function NeuralSplineLayer(
3939
) where {T1<:Int,T2<:Real}
4040
num_of_transformed_dims = length(mask_idx)
4141
input_dims = dim - num_of_transformed_dims
42-
nn = [MLP_3layer(input_dims, hdims, 3K - 1) for _ in 1:num_of_transformed_dims]
42+
nn = [mlp3(input_dims, hdims, 3K - 1) for _ in 1:num_of_transformed_dims]
4343
mask = Bijectors.PartitionMask(dim, mask_idx)
4444
return NeuralSplineLayer(dim, K, nn, B, mask)
4545
end

example/nn.jl

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)