From c8903c6d989b7c0dfd2d6633889c2678ec5e2569 Mon Sep 17 00:00:00 2001 From: sebapersson Date: Tue, 19 May 2026 13:17:44 +0100 Subject: [PATCH 1/2] Add silu/swish activation function test --- test_cases/ml_model_import/054/README.md | 7 +++ .../054/create_testdata/net.jl | 27 ++++++++++ .../054/create_testdata/net.py | 26 ++++++++++ test_cases/ml_model_import/054/net.yaml | 47 ++++++++++++++++++ .../ml_model_import/054/net_input_1.hdf5 | Bin 0 -> 2057 bytes .../ml_model_import/054/net_input_2.hdf5 | Bin 0 -> 2057 bytes .../ml_model_import/054/net_input_3.hdf5 | Bin 0 -> 2057 bytes .../ml_model_import/054/net_output_1.hdf5 | Bin 0 -> 2053 bytes .../ml_model_import/054/net_output_2.hdf5 | Bin 0 -> 2053 bytes .../ml_model_import/054/net_output_3.hdf5 | Bin 0 -> 2053 bytes test_cases/ml_model_import/054/net_ps_1.hdf5 | Bin 0 -> 4527 bytes test_cases/ml_model_import/054/net_ps_2.hdf5 | Bin 0 -> 4527 bytes test_cases/ml_model_import/054/net_ps_3.hdf5 | Bin 0 -> 4527 bytes test_cases/ml_model_import/054/solutions.yaml | 21 ++++++++ 14 files changed, 128 insertions(+) create mode 100644 test_cases/ml_model_import/054/README.md create mode 100644 test_cases/ml_model_import/054/create_testdata/net.jl create mode 100644 test_cases/ml_model_import/054/create_testdata/net.py create mode 100644 test_cases/ml_model_import/054/net.yaml create mode 100644 test_cases/ml_model_import/054/net_input_1.hdf5 create mode 100644 test_cases/ml_model_import/054/net_input_2.hdf5 create mode 100644 test_cases/ml_model_import/054/net_input_3.hdf5 create mode 100644 test_cases/ml_model_import/054/net_output_1.hdf5 create mode 100644 test_cases/ml_model_import/054/net_output_2.hdf5 create mode 100644 test_cases/ml_model_import/054/net_output_3.hdf5 create mode 100644 test_cases/ml_model_import/054/net_ps_1.hdf5 create mode 100644 test_cases/ml_model_import/054/net_ps_2.hdf5 create mode 100644 test_cases/ml_model_import/054/net_ps_3.hdf5 create mode 100644 test_cases/ml_model_import/054/solutions.yaml diff --git a/test_cases/ml_model_import/054/README.md b/test_cases/ml_model_import/054/README.md new file mode 100644 index 00000000..c3ad1704 --- /dev/null +++ b/test_cases/ml_model_import/054/README.md @@ -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. diff --git a/test_cases/ml_model_import/054/create_testdata/net.jl b/test_cases/ml_model_import/054/create_testdata/net.jl new file mode 100644 index 00000000..e1212b01 --- /dev/null +++ b/test_cases/ml_model_import/054/create_testdata/net.jl @@ -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) diff --git a/test_cases/ml_model_import/054/create_testdata/net.py b/test_cases/ml_model_import/054/create_testdata/net.py new file mode 100644 index 00000000..6d366b20 --- /dev/null +++ b/test_cases/ml_model_import/054/create_testdata/net.py @@ -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 diff --git a/test_cases/ml_model_import/054/net.yaml b/test_cases/ml_model_import/054/net.yaml new file mode 100644 index 00000000..d56ed5f7 --- /dev/null +++ b/test_cases/ml_model_import/054/net.yaml @@ -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: {} diff --git a/test_cases/ml_model_import/054/net_input_1.hdf5 b/test_cases/ml_model_import/054/net_input_1.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..595273ea0f61f55529b4a98096bbc46060c85161 GIT binary patch literal 2057 zcmeD5aB<`1lHy|G;9!7(|4_gQ6*7QI%uj5-?C;?c#H0}H$&-bQE0}~pYG4{+G#3*C zBLf2)P>xZ6ku5W?ptPj;Fw`(M5wIvnZfZ$lN@7VOD>GC=3rZ73g&lXdr_@OXVL(TM zffG@75>T|I$~BuDCkcSVg9Q{8FJTUHAz&Ag(mx{)Zw5O_5joO8Yz9U~U_3A}GBPqj z&4SU)A`Faz3i1prU~vToaSjIYdLWw>7^lo!9KbkbW@LaS5O~trK%|2Pk+K`B4rP!N zT~gra;wz{u$uCOIh)>He%1tbp0ZYVIl=!f?X`TSi=mN$ED2kYQ7(g)x%3nahff6mS ntPD#<3@5;fh6VATnK^%0cx2QQqaiQ|LO|zrto?_SKemhjzEYSe literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_input_2.hdf5 b/test_cases/ml_model_import/054/net_input_2.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..b88fe32cfe3cc035736609506a0ecc91f7eb8df5 GIT binary patch literal 2057 zcmeD5aB<`1lHy|G;9!7(|4_gQ6*7QI%uj5-?C;?c#H0}H$&-bQE0}~pYG4{+G#3*C zBLf2)P>xZ6ku5W?ptPj;Fw`(M5wIvnZfZ$lN@7VOD>GC=3rZ73g&lXdr_@OXVL(TM zffG@75>T|I$~BuDCkcSVg9Q{8FJTUHAz&Ag(mx{)Zw5O_5joO8Yz9U~U_3A}GBPqj z&4SU)A`Faz3i1prU~vToaSjIYdLWw>7^lo!9KbkbW@LaS5O~trK%|2Pk+K`B4rP!N zT~gra;wz{u$uCOIh)>He%1tbp0ZYVIl=!f?X`TSi=mN$ED2kYQ7(g)x%3nahff6mS ntPD#<3@5;fh6VATnK^%0cx2QQqaiQ|LSTda6Wf?qoc4?Wy_%PY literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_input_3.hdf5 b/test_cases/ml_model_import/054/net_input_3.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..27b6f97ef4cb0946e8b3ea886eab52d548813dc3 GIT binary patch literal 2057 zcmeD5aB<`1lHy|G;9!7(|4_gQ6*7QI%uj5-?C;?c#H0}H$&-bQE0}~pYG4{+G#3*C zBLf2)P>xZ6ku5W?ptPj;Fw`(M5wIvnZfZ$lN@7VOD>GC=3rZ73g&lXdr_@OXVL(TM zffG@75>T|I$~BuDCkcSVg9Q{8FJTUHAz&Ag(mx{)Zw5O_5joO8Yz9U~U_3A}GBPqj z&4SU)A`Faz3i1prU~vToaSjIYdLWw>7^lo!9KbkbW@LaS5O~trK%|2Pk+K`B4rP!N zT~gra;wz{u$uCOIh)>He%1tbp0ZYVIl=!f?X`TSi=mN$ED2kYQ7(g)x%3nahff6mS ntPD#<3@5;fh6VATnK^%0cx2QQqaiQ|LZHTTo1KhDi9I6#xKoz7 literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_output_1.hdf5 b/test_cases/ml_model_import/054/net_output_1.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..6daaafc79611a8993dd97aa4a17297b2576cc504 GIT binary patch literal 2053 zcmeD5aB<`1lHy|G;9!7(|4_gR6*7QIwC}jm>+j(b#H0}H$&-bQE0}~pYG4{+G#3*C zBLf4QFaral03&;TX-Pq8N%3K*X>1~3VUFC?lEjq6l0;T!sDvhzCWdlxK9obTlMKRu zt^@-|V(cWKW=BG6Iyp`f00##PC@5aS+~Y#PE+VCWMjqY_c9J4;q=DEBjEul&U}6LU zs97+YS%iU6P(hx71uU+>AkM)cUJqom0^^jKivt+n%!~}s1Oib5l-vL{WC&3z@*88w zi7qK{bnz8bmgE;DXT+!F7v(0F%z&j~D@sD3xM`jM&gcS$H51TqW*!Dm%z^S35OAPG m3kx(_U{T3%0<36Q5Xb+EFBldc8TG_y2n>P{@NlfKWds1ym6l8Z literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_output_2.hdf5 b/test_cases/ml_model_import/054/net_output_2.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..a586adb011063c8653e903e048fecbe32acd8b05 GIT binary patch literal 2053 zcmeD5aB<`1lHy|G;9!7(|4_gR6*7QIwC}jm>+j(b#H0}H$&-bQE0}~pYG4{+G#3*C zBLf4QFaral03&;TX-Pq8N%3K*X>1~3VUFC?lEjq6l0;T!sDvhzCWdlxK9obTlMKRu zt^@-|V(cWKW=BG6Iyp`f00##PC@5aS+~Y#PE+VCWMjqY_c9J4;q=DEBjEul&U}6LU zs97+YS%iU6P(hx71uU+>AkM)cUJqom0^^jKivt+n%!~}s1Oib5l-vL{WC&3z@*88w zi7qK{bnz8bmgE;DXT+!F7v(0F%z&j~D@sD3xM`jM&gcS$H51TqW*!Dm%z^S35OAPG m3kx(_U{T3%0<36Q5Xb+EFBldc8TG_y2n>P{NNBok#|Qw`JeLUo literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_output_3.hdf5 b/test_cases/ml_model_import/054/net_output_3.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..01d8a20930563daaeaa531716d4b08f2530ead79 GIT binary patch literal 2053 zcmeD5aB<`1lHy|G;9!7(|4_gR6*7QIwC}jm>+j(b#H0}H$&-bQE0}~pYG4{+G#3*C zBLf4QFaral03&;TX-Pq8N%3K*X>1~3VUFC?lEjq6l0;T!sDvhzCWdlxK9obTlMKRu zt^@-|V(cWKW=BG6Iyp`f00##PC@5aS+~Y#PE+VCWMjqY_c9J4;q=DEBjEul&U}6LU zs97+YS%iU6P(hx71uU+>AkM)cUJqom0^^jKivt+n%!~}s1Oib5l-vL{WC&3z@*88w zi7qK{bnz8bmgE;DXT+!F7v(0F%z&j~D@sD3xM`jM&gcS$H51TqW*!Dm%z^S35OAPG m3kx(_U{T3%0<36Q5Xb+EFBldc8TG_y2n>P{NcyyMKO+FwqLey_2m+nNmXlbST4eYV>L@m3QKKy^P#5SB z1jLVg__Rvj_vDpn^ODBvcd_#5owm>w$V$fys`Uivt*R%!~}sWUT>n z*8&)0@Y26EH)Y}s8(@|J1`RxHU|~W`SZF}Q0%!yTY=AL_4t+h`@-4+l*&P~c$VoYw z4H^g}C*`LTy3=t+7c?ou${1L5q4SA}J{$DtTQK;e&7>~C9B0@-lQJwUU^Fpd5daMf zSb@ke1e5aYdCz_hcnsdw6Wwomc*cHX=FNMLupUFHgb{Y82L`)_H?-M2?m+D4 z3adRt3g*3Cv=3){5!l!Rbp@Gu7#Kla7)UdN1Esqc0&N$ B95?^~ literal 0 HcmV?d00001 diff --git a/test_cases/ml_model_import/054/net_ps_2.hdf5 b/test_cases/ml_model_import/054/net_ps_2.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..055a66833c275f65597adcac673be70268a24beb GIT binary patch literal 4527 zcmeD5aB<`1lHy|G;9!7(|4^`A5F%m#m0%A4q2=%462zns?8%dbj4POgKx$wbVKf&L z10w?in-~KFqW~jUL1Iy2ZfZ$tQSo7@fovjR84jRmVoG93B7*=_LJdk2q#oXXyPq5< z0WAVLi6t+!#2^glL@;n6Xd6)qQp6|pk>ey_2m+nNmXlbST4eYV>L@m3QKKy^P#5SB z1jLVg__Rvj_vDpn^ODBvcd_#5owm>w$V$fys`Uivt*R%!~}sWUT>n z*8&)0@Y26EH)Y}s8(@|J1`RxHU|~W`SZF}Q0%!yTY=AL_4t+h`@-4+l*&P~c$VoYw z4H^g}C*`LTy3=t+7c?ou${1L5q4SA}J{$DtTQK;e&7>~C9B0@-lQJwUU^Fpd5daMf zSb@ke1e5aYdCz_hcnsz(uGs%CXxqLdUD16j+Pn9sK0URsI=X*f|Kk?>BSBO4R&_Ag zukBcCSMlhh-F>_F`{YmFvD@dOX{)m%)$Z}X1^Z5w>F>X=y5DZ+Bj)|@70&K^RCLG= z7Lfz)xlspey_2m+nNmXlbST4eYV>L@m3QKKy^P#5SB z1jLVg__Rvj_vDpn^ODBvcd_#5owm>w$V$fys`Uivt*R%!~}sWUT>n z*8&)0@Y26EH)Y}s8(@|J1`RxHU|~W`SZF}Q0%!yTY=AL_4t+h`@-4+l*&P~c$VoYw z4H^g}C*`LTy3=t+7c?ou${1L5q4SA}J{$DtTQK;e&7>~C9B0@-lQJwUU^Fpd5daMf zSb@ke1e5aYdCz_hcnm(N>9)U~_RUWGX28DQMJ@ZEnPu6#Z9cJ2@o~!@D4 z3adRt3g*3Cv=3){5!l!Rbp@Gu7#Kla7)UdN1Esqc0&N$ Date: Tue, 19 May 2026 13:18:14 +0100 Subject: [PATCH 2/2] Update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b5d772e..96e5591c 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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