Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PEtab SciML test suite

[![Build Status](https://https://github.com/PEtab-dev/petab_sciml_testsuite/actions/workflows/CI.yml/badge.svg?branch=main)](https://https://github.com/PEtab-dev/petab_sciml_testsuite/actions/workflows/CI.yml?query=branch%3Amain)
[![Build Status](https://github.com/PEtab-dev/petab_sciml_testsuite/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/PEtab-dev/petab_sciml_testsuite/actions/workflows/CI.yml?query=branch%3Amain)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![code style: runic](https://img.shields.io/badge/code_style-%E1%9A%B1%E1%9A%A2%E1%9A%BE%E1%9B%81%E1%9A%B2-black)](https://github.com/fredrikekre/Runic.jl)

Expand Down Expand Up @@ -60,9 +60,9 @@ Currently, supported and tested layers and activation functions are:
- **Layers**: `Conv1-3d`, `ConvTranspose1-3d`, `AvgPool1-3d`, `MaxPool1-3d`, `LPPool1-3d`,
`AdaptiveMaxPool1-3d`, `AdaptiveMeanPool1-3d`, `BatchNorm1-3d`, `InstanceNorm1-3d`,
`LayerNorm`, `Dropout1-3d`, `Dropout`, `AlphaDropout`, `Linear`, `Bilinear` and `Flatten`.
- **Activation**: `relu`, `relu6`, `hardtanh`, `hardswish`, `selu`, `leaky_relu`, `gelu`,
`logsigmoid`, `tanhshrink`, `softsign`, `softplus`, `tanh`, `sigmoid`, `hardsigmoid`,
`mish`, `elu`, `celu`, `softmax` and `log_softmax`.
- **Activation**: `relu`, `relu6`, `hardtanh`, `hardswish`, `selu`, `silu` `leaky_relu`,
`gelu`, `logsigmoid`, `tanhshrink`, `softsign`, `softplus`, `tanh`, `sigmoid`,
`hardsigmoid`, `mish`, `elu`, `celu`, `softmax` and `log_softmax`.

A list of supported layers and activation functions for each tool supporting PEtab SciML can
be found in the PEtab SciML
Expand Down
7 changes: 7 additions & 0 deletions test_cases/ml_model_import/054/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Net Test Case 054

Test case for testing neural network import only.

## Neural-net

A simple feed-forward network testing `silu` (often called `swish`) activation function.
27 changes: 27 additions & 0 deletions test_cases/ml_model_import/054/create_testdata/net.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Lux, StableRNGs
using PEtabSciMLTestsuite: save_ps, save_io, write_yaml

# runic: off
nn_model = @compact(
layer1 = Dense(2, 5, Lux.swish),
layer2 = Dense(5, 1),
) do x
embed = layer1(x)
out = layer2(embed)
@return out
end
# runic: on

input_order_jl, input_order_py = ["W"], ["W"]
output_order_jl, output_order_py = ["W"], ["W"]
dirsave = joinpath(@__DIR__, "..")
for i in 1:3
rng = StableRNG(i)
ps, st = Lux.setup(rng, nn_model)
input = rand(rng, Float32, 2)
output = nn_model(input, ps, st)[1]
save_ps(dirsave, i, nn_model, :net0, ps)
save_io(dirsave, i, input, input_order_jl, input_order_py, :input)
save_io(dirsave, i, output, output_order_jl, output_order_py, :output)
end
write_yaml(dirsave, input_order_jl, input_order_py, output_order_jl, output_order_py)
26 changes: 26 additions & 0 deletions test_cases/ml_model_import/054/create_testdata/net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Neural network import test generation"""

import torch
from torch import nn
from torch.nn import functional as F
from pysrc.ml_import_helper import make_yaml, test_nn


class Net(nn.Module):
def __init__(self) -> None:
super().__init__()
self.layer1 = nn.Linear(2, 5)
self.layer2 = nn.Linear(5, 1)

def forward(self, net_input: torch.Tensor) -> torch.Tensor:
x = self.layer1(net_input)
x = F.silu(x)
out = self.layer2(x)
return out


def ml_model_import_054(dir_save):
net = Net()
make_yaml(net, dir_save)
test_nn(net, dir_save, ["layer1", "layer2"])
return 0
47 changes: 47 additions & 0 deletions test_cases/ml_model_import/054/net.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
nn_model_id: net0
inputs:
- input_id: input0
layers:
- layer_id: layer1
layer_type: Linear
args:
in_features: 2
out_features: 5
bias: true
- layer_id: layer2
layer_type: Linear
args:
in_features: 5
out_features: 1
bias: true
forward:
- name: net_input
op: placeholder
target: net_input
args: []
kwargs: {}
- name: layer1
op: call_module
target: layer1
args:
- net_input
kwargs: {}
- name: silu
op: call_function
target: silu
args:
- layer1
kwargs:
inplace: false
- name: layer2
op: call_module
target: layer2
args:
- silu
kwargs: {}
- name: output
op: output
target: output
args:
- layer2
kwargs: {}
Binary file added test_cases/ml_model_import/054/net_input_1.hdf5
Binary file not shown.
Binary file added test_cases/ml_model_import/054/net_input_2.hdf5
Binary file not shown.
Binary file added test_cases/ml_model_import/054/net_input_3.hdf5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test_cases/ml_model_import/054/net_ps_1.hdf5
Binary file not shown.
Binary file added test_cases/ml_model_import/054/net_ps_2.hdf5
Binary file not shown.
Binary file added test_cases/ml_model_import/054/net_ps_3.hdf5
Binary file not shown.
21 changes: 21 additions & 0 deletions test_cases/ml_model_import/054/solutions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
input_order_py:
- "W"
net_input:
- "net_input_1.hdf5"
- "net_input_2.hdf5"
- "net_input_3.hdf5"
input_order_jl:
- "W"
output_order_jl:
- "W"
net_ps:
- "net_ps_1.hdf5"
- "net_ps_2.hdf5"
- "net_ps_3.hdf5"
net_file: "net.yaml"
output_order_py:
- "W"
net_output:
- "net_output_1.hdf5"
- "net_output_2.hdf5"
- "net_output_3.hdf5"