Innocuous Book
Search…
⌃K

Magic

Experiment with any imaginable function using our Magic Object
Wherever you are, whatever strange function you are building up, Magic Object allows you to easily develop and interact with
💀
Innocuous Book experiment.

Let's start
🔜

Instantiate Magic Object before use.
mj = MagicObj()
Then, enjoy Innocuous Book Magic power

Methods
📓

get_path

get_path(filename, path)
Search the data by filename from path , if exist, return the data path.
Arguments
filename
String (name of data with extension which you want to download)
path
String (directory where data put)
Example:
data_path = mj.get_path(
filename = "boston_housing.csv",
path = "/home/project/workspace/dataset")
data = pd.read_csv(data_path)

log

log(**kwargs)
Log metrics then you can choose one as optimal standard.
Do not use log within a Trainable class.
Arguments
**kwargs
Arguments to log which must have key
Example:
mj.log(loss=running_loss, eval_loss=eval_loss)

so u can read the data with that save ur checkpoints no matter what framework api for every single framework log you metrics

torch_get_checkpoint_path

torch_get_checkpoint_path(path, epoch)
Return the path of checkpoints during each epoch or whenever you want.
Arguments
path
String (directory where you wnat to save checkpoints)
epoch
integer (number of epochs to save the model as checkpoint. An epoch is an iteration over the entire x and y data provided)
Example:
mj.torch_get_checkpoint_path(path='/home/project/workspace/results', epoch=epoch)

torch_save

torch_save(checkpoint, path, epoch)
Save checkpoint during each epoch.
Arguments
checkpoint
Dictionary or OrderDictionary (model, weights or anything to save as checkpoint)
path
String (directory where you wnat to save checkpoints)
epoch
Integer (number of epochs to save the model as checkpoint. epoch would iterate over the entire x and y data provided)
Example:
mj.torch_save(
checkpoint = model.state_dict(),
path = '/home/project/workspace/results',
epoch = epoch)

tensor_save

tensor_save(checkpoint, path)
Save checkpoint whenever you want.
Arguments
checkpoint
Sequential object (model to save as checkpoint)
path
String (directory where you wnat to save checkpoints)
Example:
mj.tensor_save(checkpoint=model, path='/home/project/workspace/results')

callback

callback(metrics, path, frequency, on, filename=None)
Save checkpoint with the opportunity by on during each epoch and s
Arguments
metrics
Metrics in dictionary to be evaluated by the model during training and testing. Each can be a string (name of a built-in function), function or a tf.keras.metrics.Metric instance
path
String (directory where you wnat to save checkpoints)
frequency
Integer or List (if an integer n, checkpoints are saved every n times of each hook. if a list, it specifies the checkpoint frequencies for each hook individually.)
on
Integer or List (when to trigger checkpoint creations. must be one of the Keras event hooks (less the on_), e.g. "train_start", or "predict_end". defaults to "epoch_end".)
filename
String (name of checkpoint you want to save)
Example:
model.fit(
X_train, Y_train,
initial_epoch=1, epochs=epochs, batch_size=16, verbose=0,
callbacks=[m.callback(
metrics={"accuracy":"accuracy"},
filename="modelcheckpoint01",
path="/home/pj/ray_results",
frequency=1,
on="epoch_end")]
)
Last modified 1yr ago