From 9cccdf1f2843a756c22f168b18e32dedc7e1441d Mon Sep 17 00:00:00 2001 From: Henry Leung Date: Fri, 6 Sep 2024 21:35:40 -0400 Subject: [PATCH] rename GeneartorMaster to GeneratorBase --- docs/requirements.txt | 3 +-- ...astronn_master_folder.PNG => astronn_folder.png} | Bin docs/source/neuralnets/basic_usage.rst | 4 ++-- docs/source/quick_start.rst | 4 ++-- src/astroNN/models/base_bayesian_cnn.py | 8 ++++---- src/astroNN/models/base_cnn.py | 6 +++--- src/astroNN/models/base_vae.py | 6 +++--- src/astroNN/nn/utilities/generator.py | 7 +------ 8 files changed, 16 insertions(+), 22 deletions(-) rename docs/source/{astronn_master_folder.PNG => astronn_folder.png} (100%) diff --git a/docs/requirements.txt b/docs/requirements.txt index d6f9d59a..01b08c81 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,9 +1,8 @@ torch tensorflow-cpu +sphinx>=8 sphinx_rtd_theme>=3.0.0a0 sphinx-prompt sphinx-copybutton - -sphinx>=8 nbsphinx ipykernel \ No newline at end of file diff --git a/docs/source/astronn_master_folder.PNG b/docs/source/astronn_folder.png similarity index 100% rename from docs/source/astronn_master_folder.PNG rename to docs/source/astronn_folder.png diff --git a/docs/source/neuralnets/basic_usage.rst b/docs/source/neuralnets/basic_usage.rst index 39b79e92..9631b846 100644 --- a/docs/source/neuralnets/basic_usage.rst +++ b/docs/source/neuralnets/basic_usage.rst @@ -7,13 +7,13 @@ Available astroNN Neural Net Classes -------------------------------------- All astroNN Neural Nets are inherited from some child classes which inherited NeuralNetBase, NeuralNetBase also -relies relies on two major component, `Normalizer` and `GeneratorMaster` +relies relies on two major component, `Normalizer` and `GeneratorBase` :: Normalizer (astroNN.nn.utilities.normalizer.Normalizer) - GeneratorMaster (astroNN.nn.utilities.generator.GeneratorMaster) + GeneratorBase (astroNN.nn.utilities.generator.GeneratorBase) ├── CNNDataGenerator ├── Bayesian_DataGenerator └── CVAE_DataGenerator diff --git a/docs/source/quick_start.rst b/docs/source/quick_start.rst index 3062c24a..72c5f0c9 100644 --- a/docs/source/quick_start.rst +++ b/docs/source/quick_start.rst @@ -32,7 +32,7 @@ or if you want to install it in editable mode, you can run: Prerequisites --------------- -``astroNN`` requires Python 3.9 or above. The following packages are required which will be installed automatically when you install ``astroNN``: +``astroNN`` requires Python 3.10 or above. The following packages are required which will be installed automatically when you install ``astroNN``: .. literalinclude:: ../../requirements.txt @@ -225,7 +225,7 @@ How to set environment variable on different operating system: `Guide here`_ A dedicated project folder is recommended to run astroNN, always run astroNN under the root of project folder. So that astroNN will always create folder for every neural network you run under the same place. Just as below -.. image:: astronn_master_folder.PNG +.. image:: astronn_folder.png :scale: 50 % .. _Guide here: https://www.schrodinger.com/kb/1842 diff --git a/src/astroNN/models/base_bayesian_cnn.py b/src/astroNN/models/base_bayesian_cnn.py index 2502f263..092aa1f4 100644 --- a/src/astroNN/models/base_bayesian_cnn.py +++ b/src/astroNN/models/base_bayesian_cnn.py @@ -23,7 +23,7 @@ from astroNN.nn.metrics import categorical_accuracy, binary_accuracy from astroNN.nn.numpy import sigmoid from astroNN.nn.utilities import Normalizer -from astroNN.nn.utilities.generator import GeneratorMaster +from astroNN.nn.utilities.generator import GeneratorBase from astroNN.shared.dict_tools import dict_np_to_dict_list, list_to_dict from astroNN.nn.losses import ( @@ -40,7 +40,7 @@ Adam = keras.optimizers.Adam -class BayesianCNNDataGenerator(GeneratorMaster): +class BayesianCNNDataGenerator(GeneratorBase): """ To generate data to NN @@ -108,7 +108,7 @@ def on_epoch_end(self): ) -class BayesianCNNPredDataGenerator(GeneratorMaster): +class BayesianCNNPredDataGenerator(GeneratorBase): """ To generate data to NN for prediction @@ -934,7 +934,7 @@ def predict(self, input_data, inputs_err=None, batch_size=None): } def predict_dataset(self, file): - class BayesianCNNPredDataGeneratorV2(GeneratorMaster): + class BayesianCNNPredDataGeneratorV2(GeneratorBase): def __init__( self, batch_size, diff --git a/src/astroNN/models/base_cnn.py b/src/astroNN/models/base_cnn.py index edc3addb..89358b42 100644 --- a/src/astroNN/models/base_cnn.py +++ b/src/astroNN/models/base_cnn.py @@ -14,7 +14,7 @@ from astroNN.nn.losses import mean_squared_error, mean_absolute_error, mean_error from astroNN.nn.metrics import categorical_accuracy, binary_accuracy from astroNN.nn.utilities import Normalizer -from astroNN.nn.utilities.generator import GeneratorMaster +from astroNN.nn.utilities.generator import GeneratorBase from astroNN.shared.dict_tools import dict_np_to_dict_list, list_to_dict from sklearn.model_selection import train_test_split @@ -26,7 +26,7 @@ Adam = keras.optimizers.Adam -class CNNDataGenerator(GeneratorMaster): +class CNNDataGenerator(GeneratorBase): """ To generate data to NN @@ -92,7 +92,7 @@ def on_epoch_end(self): ) -class CNNPredDataGenerator(GeneratorMaster): +class CNNPredDataGenerator(GeneratorBase): """ To generate data to NN for prediction diff --git a/src/astroNN/models/base_vae.py b/src/astroNN/models/base_vae.py index 6b7a2fb9..268deaa6 100644 --- a/src/astroNN/models/base_vae.py +++ b/src/astroNN/models/base_vae.py @@ -15,7 +15,7 @@ mean_squared_reconstruction_error, ) from astroNN.nn.utilities import Normalizer -from astroNN.nn.utilities.generator import GeneratorMaster +from astroNN.nn.utilities.generator import GeneratorBase from astroNN.shared.dict_tools import dict_np_to_dict_list, list_to_dict from sklearn.model_selection import train_test_split @@ -24,7 +24,7 @@ Adam = keras.optimizers.Adam -class CVAEDataGenerator(GeneratorMaster): +class CVAEDataGenerator(GeneratorBase): """ To generate data to NN @@ -88,7 +88,7 @@ def on_epoch_end(self): ) -class CVAEPredDataGenerator(GeneratorMaster): +class CVAEPredDataGenerator(GeneratorBase): """ To generate data to NN for prediction diff --git a/src/astroNN/nn/utilities/generator.py b/src/astroNN/nn/utilities/generator.py index 8d22c25a..bf828ae2 100644 --- a/src/astroNN/nn/utilities/generator.py +++ b/src/astroNN/nn/utilities/generator.py @@ -2,13 +2,8 @@ import keras -try: - from keras.trainers.data_adapters.py_dataset_adapter import PyDataset -except ImportError: - from keras.src.trainers.data_adapters.py_dataset_adapter import PyDataset - -class GeneratorMaster(PyDataset): +class GeneratorBase(keras.utils.PyDataset): """ | Top-level class of astroNN data pipeline to generate data for NNs.