Skip to content

Commit

Permalink
Format .jl files (#161)
Browse files Browse the repository at this point in the history
Co-authored-by: prbzrg <[email protected]>
  • Loading branch information
github-actions[bot] and prbzrg authored Feb 19, 2023
1 parent c7c1424 commit 82149d2
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 50 deletions.
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# ICNF.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://impICNF.github.io/ICNF.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://impICNF.github.io/ICNF.jl/dev)
[![Build Status](https://github.com/impICNF/ICNF.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/impICNF/ICNF.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/impICNF/ICNF.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/impICNF/ICNF.jl)
[![Coverage](https://coveralls.io/repos/github/impICNF/ICNF.jl/badge.svg?branch=main)](https://coveralls.io/github/impICNF/ICNF.jl?branch=main)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

Implementations of Infinitesimal Continuous Normalizing Flows Algorithms in Julia

## Citing

See [`CITATION.bib`](CITATION.bib) for the relevant reference(s).

## Usage

To add this package, we can do it by

```julia
# ICNF.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://impICNF.github.io/ICNF.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://impICNF.github.io/ICNF.jl/dev)
[![Build Status](https://github.com/impICNF/ICNF.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/impICNF/ICNF.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/impICNF/ICNF.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/impICNF/ICNF.jl)
[![Coverage](https://coveralls.io/repos/github/impICNF/ICNF.jl/badge.svg?branch=main)](https://coveralls.io/github/impICNF/ICNF.jl?branch=main)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

Implementations of Infinitesimal Continuous Normalizing Flows Algorithms in Julia

## Citing

See [`CITATION.bib`](CITATION.bib) for the relevant reference(s).

## Usage

To add this package, we can do it by

```julia
using Pkg
Pkg.add(; url = "https://github.com/impICNF/ICNF.jl")
```

To use this package, here is an example:

```julia
```

To use this package, here is an example:

```julia
using ICNF
using Distributions, Lux
using DifferentialEquations, SciMLSensitivity
Expand Down Expand Up @@ -61,4 +61,4 @@ using Distances
mad_ = meanad(estimated_pdf, actual_pdf)
msd_ = msd(estimated_pdf, actual_pdf)
tv_dis = totalvariation(estimated_pdf, actual_pdf) / n
```
```
16 changes: 14 additions & 2 deletions src/core_cond_icnf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,23 @@ function CondICNFModel(
optimizer::Any = Optimisers.Adam(),
n_epochs::Integer = 128,
adtype::SciMLBase.AbstractADType = Optimization.AutoZygote(),
use_batch::Bool=true,
use_batch::Bool = true,
batch_size::Integer = 128,
resource::AbstractResource = CPU1(),
) where {T <: AbstractFloat, AT <: AbstractArray, CM <: ComputeMode}
CondICNFModel(m, loss, optimizer, n_epochs, adtype, use_batch, batch_size, resource, T, AT, CM)
CondICNFModel(
m,
loss,
optimizer,
n_epochs,
adtype,
use_batch,
batch_size,
resource,
T,
AT,
CM,
)
end

function MLJModelInterface.fit(model::CondICNFModel, verbosity, XY)
Expand Down
16 changes: 14 additions & 2 deletions src/core_icnf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,23 @@ function ICNFModel(
optimizer::Any = Optimisers.Adam(),
n_epochs::Integer = 128,
adtype::SciMLBase.AbstractADType = Optimization.AutoZygote(),
use_batch::Bool=true,
use_batch::Bool = true,
batch_size::Integer = 128,
resource::AbstractResource = CPU1(),
) where {T <: AbstractFloat, AT <: AbstractArray, CM <: ComputeMode}
ICNFModel(m, loss, optimizer, n_epochs, adtype, use_batch, batch_size, resource, T, AT, CM)
ICNFModel(
m,
loss,
optimizer,
n_epochs,
adtype,
use_batch,
batch_size,
resource,
T,
AT,
CM,
)
end

function MLJModelInterface.fit(model::ICNFModel, verbosity, X)
Expand Down
38 changes: 19 additions & 19 deletions src/flux_compat.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export MyFluxLayer

struct MyFluxLayer{L, RE, I} <: LuxCore.AbstractExplicitLayer
layer::L
re::RE
init_parameters::I
end

function MyFluxLayer(l)
p, re = Optimisers.destructure(l)
p_ = copy(p)
return MyFluxLayer(l, re, () -> p_)
end

Lux.initialparameters(::AbstractRNG, l::MyFluxLayer) = l.init_parameters()

(l::MyFluxLayer)(x, ps, st) = l.re(ps)(x), st

Base.show(io::IO, l::MyFluxLayer) = print(io, "MyFluxLayer($(l.layer))")
export MyFluxLayer

struct MyFluxLayer{L, RE, I} <: LuxCore.AbstractExplicitLayer
layer::L
re::RE
init_parameters::I
end

function MyFluxLayer(l)
p, re = Optimisers.destructure(l)
p_ = copy(p)
return MyFluxLayer(l, re, () -> p_)
end

Lux.initialparameters(::AbstractRNG, l::MyFluxLayer) = l.init_parameters()

(l::MyFluxLayer)(x, ps, st) = l.re(ps)(x), st

Base.show(io::IO, l::MyFluxLayer) = print(io, "MyFluxLayer($(l.layer))")

0 comments on commit 82149d2

Please sign in to comment.