Function reconstruction¶
refann.refann¶
-
class
refann.refann.ANN(data, hidden_layer=1, mid_node=4096, hp_model='rec_1', loss_func='L1')[source]¶ Bases:
refann.train.TrainReconstruct functions with Artificial Neural Network.
Parameters: - data (array-like) – An array with shape of (N, 3), where N is the number of data points, each column represents \(X, Y, \sigma_Y\).
- hidden_layer (int, optional) – The number of hidden layers. Default: 1
- mid_node (int, optional) – The number of nodes (or neurons) of the middle layer. Default: 4096
- hp_model (int, optional) – The hyperparameter models, ‘rec_1’ (no batch normalization) or ‘rec_2’ (with batch normalization). Default: ‘rec_1’
- loss_func (str, optional) – The loss function, there are three loss functions in this code, L1Loss (‘L1’), MSELoss (‘MSE’), and SmoothL1Loss (‘SmoothL1’). Default: ‘L1’
Variables: - lr (float, optional) – The learning rate. Default: 1e-1
- lr_min (float, optional) – The minimum of the learning rate. Default: 1e-8
- iteration (int, optional) – The number of iterations. Default: 30000
- batch_size_max (int, optional) – The maximum of the batch size. Defalt: 300
- scale_inputs (bool, optional) – If True, the inputs data will be normalized, otherwise, do nothing. Defalt: True
- scale_target (bool, optional) – If True, the outputs (or target) data will be normalized, otherwise, do nothing. Defalt: True
- scale_type (str, optional) – The normalization method, ‘minmax’, ‘mean’, or ‘z_score’. Default: ‘z_score’
- fix_initialize (bool, optional) – If True, the network will be initialized from a specific seed. Default: True
- print_info (bool, optional) – If True, some information about the training process will be printed. Default: True
Note
Hyperparameters of the ANN, such as the number of hidden layers (
hidden_layer), the number of neurons (mid_node), hyperparameter model (hp_model), should be optimized before reconstructing functions from data. See https://doi.org/10.3847/1538-4365/ab620b for details.
-
class
refann.refann.OptimizeANN(truth, hidden_layers=[1, 2, 3], mid_nodes=[128, 256])[source]¶ Bases:
object
-
class
refann.refann.RePredictANN(data, hidden_layer=1, mid_node=4096)[source]¶ Bases:
refann.refann.ANNReconstruct function using the saved well-trained networks
Parameters: Variables: - scale_inputs (bool, optional) – If True, the inputs data will be normalized, otherwise, do nothing. Defalt: True
- scale_target (bool, optional) – If True, the outputs (or target) data will be normalized, otherwise, do nothing. Defalt: True
- scale_type (str, optional) – The normalization method, ‘minmax’, ‘mean’, or ‘z_score’. Default: ‘z_score’
refann.evaluate¶
refann.save¶
-
refann.save.mkdir(path)[source]¶ Make a directory in a particular location if it is not exists, otherwise, do nothing.
Parameters: path (str) – The path of a file. Examples
>>> mkdir('/home/UserName/test') >>> mkdir('test/one') >>> mkdir('../test/one')