|
39 | 39 |
|
40 | 40 | @functor AffineCoupling (s, t)
|
41 | 41 |
|
42 |
| -function AffineCoupling( |
43 |
| - dim::Int, # dimension of the problem |
44 |
| - hdims::AbstractVector{Int}, # dimension of hidden units for s and t |
45 |
| - mask_idx::AbstractVector{Int}, # indices of the transformed dimensions |
| 42 | +function AffineCoupling( |
| 43 | + dim::Int, |
| 44 | + hdims::AbstractVector{Int}, |
| 45 | + mask_idx::AbstractVector{Int}, |
46 | 46 | paramtype::Type{T}
|
47 | 47 | ) where {T<:AbstractFloat}
|
48 | 48 | cdims = length(mask_idx) # dimension of parts used to construct coupling law
|
@@ -130,9 +130,9 @@ Example
|
130 | 130 | - `y = layer(randn(4, 16))` # batched forward
|
131 | 131 | """
|
132 | 132 | function RealNVP_layer(
|
133 |
| - dims::Int, # dimension of problem |
134 |
| - hdims::AbstractVector{Int}; # dimension of hidden units for s and t |
135 |
| - paramtype::Type{T} = Float64, # type of the parameters |
| 133 | + dims::Int, |
| 134 | + hdims::AbstractVector{Int}; |
| 135 | + paramtype::Type{T} = Float64, |
136 | 136 | ) where {T<:AbstractFloat}
|
137 | 137 |
|
138 | 138 | mask_idx1 = 1:2:dims
|
@@ -169,12 +169,12 @@ Example
|
169 | 169 | """
|
170 | 170 | function realnvp(
|
171 | 171 | q0::Distribution{Multivariate,Continuous},
|
172 |
| - hdims::AbstractVector{Int}, # dimension of hidden units for s and t |
173 |
| - nlayers::Int; # number of RealNVP_layer |
174 |
| - paramtype::Type{T} = Float64, # type of the parameters |
| 172 | + hdims::AbstractVector{Int}, |
| 173 | + nlayers::Int; |
| 174 | + paramtype::Type{T} = Float64, |
175 | 175 | ) where {T<:AbstractFloat}
|
176 | 176 |
|
177 |
| - dims = length(q0) # dimension of the reference distribution == dim of the problem |
| 177 | + dims = length(q0) |
178 | 178 | Ls = [RealNVP_layer(dims, hdims; paramtype=paramtype) for _ in 1:nlayers]
|
179 | 179 | create_flow(Ls, q0)
|
180 | 180 | end
|
|
0 commit comments