# NeuroStage
"NeuroStage is a framework that allows users to create and manage deep learning projects in a structured and modular way, adapted for TensorFlow. It includes integration with tools like Tensorboard, enabling users to efficiently track and improve their models."
# Purpose
NeuroStage was born from the idea of automatically generating projects, with a specific focus on building deep learning models using TensorFlow. It is a tool designed for new users who need a standard structure without having to worry about organizing the project from scratch.
# Índice
1. [Design](#Design)
2. [Features](#Features)
3. [Installation](#installation)
4. [Usage Flow](#usage-flow)
# Design
It is designed as a layer-based pattern (for building modules, architectures, and training) which is excellent for organizing a TensorFlow framework for deep learning testing. This modular approach facilitates integration with TensorBoard and promotes scalability.
## Modules
**Layers** Define base layers here (e.g., convolutional, attention, etc.) that can be used in models. These layers form the building blocks for your deep learning models.
**Models** Combine the layers to create specific architectures for evaluation. This module allows you to design and implement various deep learning models by reusing and combining different layers.
**Training** Conduct experiments with specific configurations, logging metrics, parameters, and artifacts. This module focuses on the training process, helping you to configure and run training sessions, and track the performance and results.
# Features
| Feature | DeepTrain |
|--------------------------|--------------------------------------------------------|
| Model Management | Allows customization for versioning and saving models. |
| Test Automation | Executes each training session in series as defined by the training module. | |
| Tool Compatibility | TensorFlow, TensorBoard, OpenCV, Numpy |
| Open Source | MIT License |
| Flexibility | Preconfigured but flexible, define rules and processes as per your case |
| Collaboration | Avalable |
## Project Structure
```
my_project/
│
├── config.py # Project configuration file
├── utils.py # General utilities file
├── functions.py # Training functions file
├── imports.py # Library imports file
├── experiments/ # Folder for experiments
└── src/ # Main source code folder
├── layers/ # Folder for implementing custom layers
│ └── layer_a.py # Example content
│ └── layer_b.py
├── models/ # Folder for defining models
│ └── model_a.py # Example content
│ └── model_b.py
└── training/ # Folder for compiling and starting training
└── train_a.py # Example content
└── train_b.py
```
# Installation
To install **NeuroStage**, simply run the following command:
```
pip install neurostage
```
For more detailed information, visit the project page on Github:
[NeuroStage](https://github.com/catalina-delgado/NeuroStage)
## stage
To confirm that the installation was successful, run the following command:
```
stage
```
You should see the following output:
```
usage: stage [-h] [--list] [--help_train] {startproject,run} ...
NeuroStage: A framework for testing and training deep learning models.
positional arguments:
{startproject,run}
startproject Start a New Project
run Run the current project
options:
-h, --help show this help message and exit
--list List the available models
--help_train Show usage examples
```
If you see this message, the installation has been completed successfully and the `stage` command is ready to use.
# Usage-Flow
## Start a new project
To start a new project, use the following command. You can replace `my_project` with your desired project name:
```
stage startproject my_project
```
## create a new layer
File: src/layers/layer_custom.py
```python
from imports import tf
class CustomLayer(tf.keras.layers.Layer):
def __init__(self, units, **kwargs):
super().__init__(**kwargs)
self.units = units
self.dense = tf.keras.layers.Dense(units)
def call(self, inputs):
return self.dense(inputs)
```
## create a new model
File: src/models/model_custom.py
```python
from imports import tf
from src.layers.layer_custom import CustomLayer
class ModelCustom():
def __init__(self):
super(Model, self).__init__()
self.layer = CustomLayer(64)
def build_model(self, input):
x = self.layer(input)
x = self.layer(x)
x = self.layer(x)
model = tf.keras.Model(inputs=input, outputs=x)
return model
```
## Create a training runner
File: src/training/train_custom.py
```python
from functions import NeuroStage
from imports import tf, np
from src.models.model import Model
class TrainModel(NeuroStage):
def __init__(self, batch_size=32, epochs=4, model_name='', models=None):
super().__init__()
self.BATCH_SIZE = batch_size
self.EPHOCS = epochs
self.MODEL_NAME = model_name
input = tf.keras.Input(shape=(256, 256, 1))
self.optimizer = tf.keras.optimizers.SGD(learning_rate=1e-3, momentum=0.95)
self.architecture = Model()
print(models)
self.model = self.architecture.build_model(input)
self.model.compile(optimizer=self.optimizer,
loss='binary_crossentropy',
metrics=['accuracy'])
def train(self):
X_train = np.random.rand(100, 256, 256, 1)
y_train = np.random.randint(0, 2, 100)
X_val = np.random.rand(20, 256, 256, 1)
y_val = np.random.randint(0, 2, 20)
self.init_fit(self.model, X_train, y_train, X_val, y_val, self.EPHOCS, self.BATCH_SIZE, self.MODEL_NAME)
```
## Execution
```
stage run --batch_size 32 --epochs 10 --model_name my_model
```
Raw data
{
"_id": null,
"home_page": "https://github.com/catalina-delgado/NeuroStage",
"name": "neurostage",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "training, deepLearning, framework",
"author": "Catalina Delgado",
"author_email": "catalina08delgado@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ed/8b/51eed8048fc7f6c0e9166b9b2029436a2106afef11e7ff0c4993107fa317/neurostage-0.2.tar.gz",
"platform": null,
"description": "# NeuroStage\r\n\"NeuroStage is a framework that allows users to create and manage deep learning projects in a structured and modular way, adapted for TensorFlow. It includes integration with tools like Tensorboard, enabling users to efficiently track and improve their models.\"\r\n\r\n# Purpose\r\nNeuroStage was born from the idea of automatically generating projects, with a specific focus on building deep learning models using TensorFlow. It is a tool designed for new users who need a standard structure without having to worry about organizing the project from scratch.\r\n\r\n# \u00cdndice\r\n\r\n1. [Design](#Design)\r\n2. [Features](#Features)\r\n3. [Installation](#installation) \r\n4. [Usage Flow](#usage-flow)\r\n\r\n# Design\r\nIt is designed as a layer-based pattern (for building modules, architectures, and training) which is excellent for organizing a TensorFlow framework for deep learning testing. This modular approach facilitates integration with TensorBoard and promotes scalability. \r\n\r\n## Modules\r\n\r\n**Layers** Define base layers here (e.g., convolutional, attention, etc.) that can be used in models. These layers form the building blocks for your deep learning models.\r\n\r\n**Models** Combine the layers to create specific architectures for evaluation. This module allows you to design and implement various deep learning models by reusing and combining different layers.\r\n\r\n**Training** Conduct experiments with specific configurations, logging metrics, parameters, and artifacts. This module focuses on the training process, helping you to configure and run training sessions, and track the performance and results.\r\n\r\n# Features\r\n\r\n| Feature | DeepTrain |\r\n|--------------------------|--------------------------------------------------------|\r\n| Model Management | Allows customization for versioning and saving models. |\r\n| Test Automation | Executes each training session in series as defined by the training module. | |\r\n| Tool Compatibility | TensorFlow, TensorBoard, OpenCV, Numpy |\r\n| Open Source | MIT License |\r\n| Flexibility | Preconfigured but flexible, define rules and processes as per your case |\r\n| Collaboration | Avalable |\r\n\r\n\r\n## Project Structure\r\n```\r\nmy_project/\r\n\u2502\r\n\u251c\u2500\u2500 config.py # Project configuration file\r\n\u251c\u2500\u2500 utils.py # General utilities file\r\n\u251c\u2500\u2500 functions.py # Training functions file\r\n\u251c\u2500\u2500 imports.py # Library imports file\r\n\u251c\u2500\u2500 experiments/ # Folder for experiments\r\n\u2514\u2500\u2500 src/ # Main source code folder\r\n \u251c\u2500\u2500 layers/ # Folder for implementing custom layers\r\n \u2502 \u2514\u2500\u2500 layer_a.py # Example content\r\n \u2502 \u2514\u2500\u2500 layer_b.py \r\n \u251c\u2500\u2500 models/ # Folder for defining models\r\n \u2502 \u2514\u2500\u2500 model_a.py # Example content\r\n \u2502 \u2514\u2500\u2500 model_b.py \r\n \u2514\u2500\u2500 training/ # Folder for compiling and starting training\r\n \u2514\u2500\u2500 train_a.py # Example content\r\n \u2514\u2500\u2500 train_b.py\r\n```\r\n# Installation\r\nTo install **NeuroStage**, simply run the following command:\r\n``` \r\npip install neurostage\r\n```\r\nFor more detailed information, visit the project page on Github:\r\n[NeuroStage](https://github.com/catalina-delgado/NeuroStage)\r\n\r\n## stage\r\nTo confirm that the installation was successful, run the following command:\r\n```\r\nstage\r\n```\r\nYou should see the following output:\r\n```\r\nusage: stage [-h] [--list] [--help_train] {startproject,run} ...\r\n\r\nNeuroStage: A framework for testing and training deep learning models.\r\n\r\npositional arguments:\r\n {startproject,run}\r\n startproject Start a New Project\r\n run Run the current project\r\n\r\noptions:\r\n -h, --help show this help message and exit\r\n --list List the available models\r\n --help_train Show usage examples\r\n```\r\nIf you see this message, the installation has been completed successfully and the `stage` command is ready to use.\r\n\r\n# Usage-Flow\r\n## Start a new project\r\nTo start a new project, use the following command. You can replace `my_project` with your desired project name:\r\n```\r\nstage startproject my_project\r\n```\r\n## create a new layer\r\nFile: src/layers/layer_custom.py\r\n```python\r\nfrom imports import tf\r\n\r\nclass CustomLayer(tf.keras.layers.Layer):\r\n def __init__(self, units, **kwargs):\r\n super().__init__(**kwargs)\r\n self.units = units\r\n self.dense = tf.keras.layers.Dense(units)\r\n\r\n def call(self, inputs):\r\n return self.dense(inputs)\r\n\r\n```\r\n## create a new model\r\nFile: src/models/model_custom.py\r\n```python\r\nfrom imports import tf\r\nfrom src.layers.layer_custom import CustomLayer\r\n\r\nclass ModelCustom():\r\n def __init__(self): \r\n super(Model, self).__init__() \r\n self.layer = CustomLayer(64)\r\n\r\n\r\n def build_model(self, input):\r\n x = self.layer(input)\r\n x = self.layer(x)\r\n x = self.layer(x)\r\n\r\n model = tf.keras.Model(inputs=input, outputs=x)\r\n\r\n return model\r\n```\r\n## Create a training runner\r\nFile: src/training/train_custom.py\r\n```python\r\nfrom functions import NeuroStage\r\nfrom imports import tf, np\r\nfrom src.models.model import Model\r\n\r\nclass TrainModel(NeuroStage):\r\n def __init__(self, batch_size=32, epochs=4, model_name='', models=None):\r\n super().__init__()\r\n\r\n self.BATCH_SIZE = batch_size\r\n self.EPHOCS = epochs\r\n self.MODEL_NAME = model_name\r\n\r\n input = tf.keras.Input(shape=(256, 256, 1)) \r\n self.optimizer = tf.keras.optimizers.SGD(learning_rate=1e-3, momentum=0.95)\r\n self.architecture = Model()\r\n print(models)\r\n self.model = self.architecture.build_model(input)\r\n self.model.compile(optimizer=self.optimizer,\r\n loss='binary_crossentropy',\r\n metrics=['accuracy'])\r\n\r\n def train(self):\r\n X_train = np.random.rand(100, 256, 256, 1)\r\n y_train = np.random.randint(0, 2, 100) \r\n X_val = np.random.rand(20, 256, 256, 1) \r\n y_val = np.random.randint(0, 2, 20)\r\n\r\n self.init_fit(self.model, X_train, y_train, X_val, y_val, self.EPHOCS, self.BATCH_SIZE, self.MODEL_NAME)\r\n```\r\n## Execution\r\n```\r\nstage run --batch_size 32 --epochs 10 --model_name my_model\r\n```\r\n\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A framework for managing deep learning projects",
"version": "0.2",
"project_urls": {
"Homepage": "https://github.com/catalina-delgado/NeuroStage"
},
"split_keywords": [
"training",
" deeplearning",
" framework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "52c39877aaef7f60b13bc695f73384716c9698640ba2e1b0a2ff4d052325c94a",
"md5": "5d4d0f8aa37b3996918fc6ad74efe253",
"sha256": "e5563a898d948818f7923f68d34bdbb0fbbd1b2bb9ecf259212ea6b3ca54e99f"
},
"downloads": -1,
"filename": "neurostage-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d4d0f8aa37b3996918fc6ad74efe253",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8731,
"upload_time": "2025-01-20T01:41:50",
"upload_time_iso_8601": "2025-01-20T01:41:50.283136Z",
"url": "https://files.pythonhosted.org/packages/52/c3/9877aaef7f60b13bc695f73384716c9698640ba2e1b0a2ff4d052325c94a/neurostage-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ed8b51eed8048fc7f6c0e9166b9b2029436a2106afef11e7ff0c4993107fa317",
"md5": "6cb701805f66e4b4e521d3bd3e3d58a3",
"sha256": "27e857d92a11add0637e2d37dae2c1f9fcdf0e33beb7d61dfa9ff5bbfc029ac4"
},
"downloads": -1,
"filename": "neurostage-0.2.tar.gz",
"has_sig": false,
"md5_digest": "6cb701805f66e4b4e521d3bd3e3d58a3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 8784,
"upload_time": "2025-01-20T01:41:52",
"upload_time_iso_8601": "2025-01-20T01:41:52.719109Z",
"url": "https://files.pythonhosted.org/packages/ed/8b/51eed8048fc7f6c0e9166b9b2029436a2106afef11e7ff0c4993107fa317/neurostage-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-20 01:41:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "catalina-delgado",
"github_project": "NeuroStage",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "neurostage"
}