diff --git a/examples/README.md b/examples/README.md index 74161c1..39f1b1d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,6 +7,6 @@ The following are the currently available examples: - [Complex Model](./complex_model): shows how to build more intricate model architectures using Nada AI. Contains convolutions, pooling operations, linear layers and activations - [Time Series](./time_series): shows how to run a Facebook Prophet time series forecasting model using Nada AI -The Nada program source code is stored in `src/main.py`. +The Nada program source code is stored in `src/.py`. In order to follow the end-to-end example, head to `network/compute.py`. You can run it by simply running `nada build` to build the Nada program followed by `python network/compute.py`. diff --git a/examples/complex_model/nada-project.toml b/examples/complex_model/nada-project.toml index aaa7360..0c95e19 100644 --- a/examples/complex_model/nada-project.toml +++ b/examples/complex_model/nada-project.toml @@ -3,5 +3,5 @@ version = "0.1.0" authors = [""] [[programs]] -path = "src/main.py" +path = "src/complex_model.py" prime_size = 128 diff --git a/examples/complex_model/src/main.py b/examples/complex_model/src/complex_model.py similarity index 100% rename from examples/complex_model/src/main.py rename to examples/complex_model/src/complex_model.py diff --git a/examples/complex_model/tests/complex_model.yaml b/examples/complex_model/tests/complex_model.yaml index 43e1974..9a30a2c 100644 --- a/examples/complex_model/tests/complex_model.yaml +++ b/examples/complex_model/tests/complex_model.yaml @@ -1,5 +1,5 @@ --- -program: main +program: complex_model inputs: secrets: # We assume all values were originally floats, scaled & rounded by a factor of 2**16 diff --git a/examples/linear_regression/nada-project.toml b/examples/linear_regression/nada-project.toml index c64354d..3b69c79 100644 --- a/examples/linear_regression/nada-project.toml +++ b/examples/linear_regression/nada-project.toml @@ -3,5 +3,5 @@ version = "0.1.0" authors = [""] [[programs]] -path = "src/main.py" +path = "src/linear_regression.py" prime_size = 128 diff --git a/examples/linear_regression/src/main.py b/examples/linear_regression/src/linear_regression.py similarity index 100% rename from examples/linear_regression/src/main.py rename to examples/linear_regression/src/linear_regression.py diff --git a/examples/linear_regression/tests/linear_regression.yaml b/examples/linear_regression/tests/linear_regression.yaml index 6e20d1b..cf8c05d 100644 --- a/examples/linear_regression/tests/linear_regression.yaml +++ b/examples/linear_regression/tests/linear_regression.yaml @@ -1,5 +1,5 @@ --- -program: main +program: linear_regression inputs: secrets: # We assume all values were originally floats, scaled & rounded by a factor of 2**16 diff --git a/examples/neural_net/nada-project.toml b/examples/neural_net/nada-project.toml index aaa7360..1ac31f6 100644 --- a/examples/neural_net/nada-project.toml +++ b/examples/neural_net/nada-project.toml @@ -1,7 +1,7 @@ -name = "complex_model" +name = "neural_net" version = "0.1.0" authors = [""] [[programs]] -path = "src/main.py" +path = "src/neural_net.py" prime_size = 128 diff --git a/examples/neural_net/src/main.py b/examples/neural_net/src/neural_net.py similarity index 100% rename from examples/neural_net/src/main.py rename to examples/neural_net/src/neural_net.py diff --git a/examples/neural_net/tests/neural_net.yaml b/examples/neural_net/tests/neural_net.yaml index 7fec66a..bb15100 100644 --- a/examples/neural_net/tests/neural_net.yaml +++ b/examples/neural_net/tests/neural_net.yaml @@ -1,5 +1,5 @@ --- -program: main +program: neural_net inputs: secrets: # We assume all values were originally floats, scaled & rounded by a factor of 2**16 diff --git a/examples/time_series/nada-project.toml b/examples/time_series/nada-project.toml index 15f098a..b8f6a35 100644 --- a/examples/time_series/nada-project.toml +++ b/examples/time_series/nada-project.toml @@ -3,5 +3,5 @@ version = "0.1.0" authors = [""] [[programs]] -path = "src/main.py" +path = "src/time_series.py" prime_size = 128 diff --git a/examples/time_series/src/main.py b/examples/time_series/src/time_series.py similarity index 100% rename from examples/time_series/src/main.py rename to examples/time_series/src/time_series.py diff --git a/examples/time_series/tests/time_series.yaml b/examples/time_series/tests/time_series.yaml index 7497d2b..b0e2b98 100644 --- a/examples/time_series/tests/time_series.yaml +++ b/examples/time_series/tests/time_series.yaml @@ -1,5 +1,5 @@ --- -program: main +program: time_series inputs: secrets: my_prophet_changepoints_t_8: diff --git a/nada_ai/client.py b/nada_ai/client.py index 50eff14..a7bc824 100644 --- a/nada_ai/client.py +++ b/nada_ai/client.py @@ -159,7 +159,7 @@ def __init__(self, model: sklearn.base.BaseEstimator) -> None: class ProphetClient(ModelClient): """ModelClient for Prophet models""" - def __init__(self, model) -> None: + def __init__(self, model: "prophet.forecaster.Prophet") -> None: """ Client initialization. diff --git a/nada_ai/time_series/prophet.py b/nada_ai/time_series/prophet.py index 38d4e54..7110a46 100644 --- a/nada_ai/time_series/prophet.py +++ b/nada_ai/time_series/prophet.py @@ -197,10 +197,8 @@ def predict( Returns: na.NadaArray: Forecasted values. """ - assert len(dates) == len( - floor - ), "Provided Prophet inputs must be equally sized." - assert len(floor) == len(t), "Provided Prophet inputs must be equally sized." + assert len(dates) == len(floor), "Prophet inputs must be equally sized." + assert len(floor) == len(t), "Prophet inputs must be equally sized." dates = self.ensure_numeric_dates(dates) trend = self.predict_trend(floor, t) @@ -221,7 +219,9 @@ def ensure_numeric_dates(self, dates: np.ndarray) -> np.ndarray: Returns: np.ndarray: Standardized dates. """ - if np.issubdtype(dates.dtype, (np.integer, np.floating)): + if np.issubdtype(dates.dtype, np.integer) or np.issubdtype( + dates.dtype, np.floating + ): return dates if np.issubdtype(dates.dtype, np.datetime64): return dates.astype(np.float64) diff --git a/tests/python-tests/test_nn.py b/tests/python-tests/test_nn.py index 92e056b..af18282 100644 --- a/tests/python-tests/test_nn.py +++ b/tests/python-tests/test_nn.py @@ -79,8 +79,6 @@ def forward(x: na.NadaArray) -> na.NadaArray: ... def test_parameters_5(self): param = Parameter((2, 3)) - assert param[0][0] == Integer(0) - alphas = na.alphas((2, 3), alpha=Integer(42)) param.load_state(alphas) @@ -96,9 +94,6 @@ def forward(x: na.NadaArray) -> na.NadaArray: ... mod = TestModule() - for _, param in mod.named_parameters(): - assert param[0][0] == Integer(0) - alphas = na.alphas((2, 3), alpha=Integer(42)) for _, param in mod.named_parameters(): @@ -124,9 +119,6 @@ def forward(x: na.NadaArray) -> na.NadaArray: ... mod = TestModule2() - for _, param in mod.named_parameters(): - assert param[0][0] == Integer(0) - alphas = na.alphas((2, 3), alpha=Integer(42)) for _, param in mod.named_parameters(): @@ -138,8 +130,6 @@ def forward(x: na.NadaArray) -> na.NadaArray: ... def test_parameters_8(self): param = Parameter((2, 3)) - assert param[0][0] == Integer(0) - alphas = na.alphas((3, 3), alpha=Integer(42)) with pytest.raises(MismatchedShapesException):