-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from t-bz/relative_paths
Allow relative paths in YAML files and update docs
- Loading branch information
Showing
26 changed files
with
1,379 additions
and
1,194 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
# Models | ||
|
||
::: lume_model.models | ||
selection: | ||
::: lume_model.base | ||
options: | ||
members: | ||
- BaseModel | ||
rendering: | ||
show_root_heading: false | ||
- LUMEBaseModel | ||
|
||
::: lume_model.models.torch_model | ||
options: | ||
members: | ||
- TorchModel | ||
|
||
::: lume_model.models.torch_module | ||
options: | ||
members: | ||
- TorchModule | ||
|
||
::: lume_model.models.keras_model | ||
options: | ||
members: | ||
- KerasModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# Utilities | ||
|
||
::: lume_model.utils | ||
rendering: | ||
show_root_heading: false | ||
options: | ||
members: | ||
- variables_as_yaml | ||
- variables_from_dict | ||
- variables_from_yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# Variables | ||
|
||
::: lume_model.variables | ||
selection: | ||
options: | ||
members: | ||
- Variable | ||
- ScalarVariable | ||
- InputVariable | ||
- OutputVariable | ||
- ScalarInputVariable | ||
- ScalarOutputVariable | ||
- ImageInputVariable | ||
- ImageOutputVariable | ||
- ArrayInputVariable | ||
- ArrayOutputVariable | ||
- TableVariable | ||
rendering: | ||
show_source: true |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "235c92cd-cc05-42b8-a516-1185eeac5f0c", | ||
"metadata": {}, | ||
"source": [ | ||
"# Creating a Custom LUME-model\n", | ||
"Custom models that are compatible with LUME tools can be created by inhereting from the `LUMEBaseModel`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "56725817-2b21-4bea-98b0-151dea959f77", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from lume_model.base import LUMEBaseModel\n", | ||
"from lume_model.variables import ScalarInputVariable, ScalarOutputVariable" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "79c62b18-7dc1-44ca-b578-4dea5cc4a4b4", | ||
"metadata": {}, | ||
"source": [ | ||
"## Model Definition\n", | ||
"The minimum requirement for creating a custom LUME-model is to implement the abstract `evaluate` method inherited from `LUMEBaseModel`. Here, we simply return the squared input." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "f96d9863-269c-49d8-9671-cc73a783bcbc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"class ExampleModel(LUMEBaseModel):\n", | ||
" def evaluate(self, input_dict):\n", | ||
" output_dict = {\n", | ||
" \"output1\": input_dict[self.input_variables[0].name] ** 2,\n", | ||
" \"output2\": input_dict[self.input_variables[1].name] ** 2,\n", | ||
" }\n", | ||
" return output_dict" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "868fff4d-1f46-48e2-8bd0-c9d831df79e6", | ||
"metadata": {}, | ||
"source": [ | ||
"## Model Instantiation and Execution\n", | ||
"Instantiation requires specification of the input and output variables of the model." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "97946e64-062d-47d4-8d0c-d7e02a335a56", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"input_variables = [\n", | ||
" ScalarInputVariable(name=\"input1\", default=0.1, value_range=[0.0, 1.0]),\n", | ||
" ScalarInputVariable(name=\"input2\", default=0.2, value_range=[0.0, 1.0]),\n", | ||
"]\n", | ||
"output_variables = [\n", | ||
" ScalarOutputVariable(name=\"output1\"),\n", | ||
" ScalarOutputVariable(name=\"output2\"),\n", | ||
"]\n", | ||
"\n", | ||
"m = ExampleModel(input_variables=input_variables, output_variables=output_variables)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "50aae4be-0d6e-456f-83e8-3a84d6d78f84", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'output1': 0.09, 'output2': 0.36}" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"input_dict = {\n", | ||
" \"input1\": 0.3,\n", | ||
" \"input2\": 0.6,\n", | ||
"}\n", | ||
"m.evaluate(input_dict)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6a547f3c-1706-4b32-bab6-9687627f6a78", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [conda env:lume-model-dev]", | ||
"language": "python", | ||
"name": "conda-env-lume-model-dev-py" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Binary file not shown.
Oops, something went wrong.