Skip to content

Rackio LSTM

class rackio_AI.RackioLSTM(*args, **kwargs)

Documentation here

call(self, *args, **kwargs)

Wraps call, applying pre- and post-processing steps.

Arguments: args: Positional arguments to be passed to self.call. *kwargs: Keyword arguments to be passed to self.call.

Returns: Output tensor(s).

Note: - The following optional keyword arguments are reserved for specific uses: * training: Boolean scalar tensor of Python boolean indicating whether the call is meant for training or inference. * mask: Boolean input mask. - If the layer's call method takes a mask argument (as some Keras layers do), its default value will be set to the mask generated for inputs by the previous layer (if input did come from a layer that generated a corresponding mask, i.e. if it came from a Keras layer with masking support.

Raises: ValueError: if the layer's call method returns None (an invalid value). RuntimeError: if super().init() was not called in the constructor.

compile(self, optimizer=, loss='mse', metrics=, loss_weights=None, weighted_metrics=None, run_eagerly=None, steps_per_execution=None, **kwargs)

Configures the model for training.

Parameters

  • :param optimizer: String (name of optimizer) or optimizer instance.
  • :param loss: String (name of objective function), objective function or tf.keras.losses.Loss instance. See tf.keras.losses. An objective function is any callable with the signature loss = fn(y_true, y_pred), where y_true = ground truth values with shape = [batch_size, d0, .. dN], except sparse loss functions such as sparse categorical crossentropy where shape = [batch_size, d0, .. dN-1]. y_pred = predicted values with shape = [batch_size, d0, .. dN]. It returns a weighted loss float tensor. If a custom Loss instance is used and reduction is set to NONE, return value has the shape [batch_size, d0, .. dN-1] ie. per-sample or per-timestep loss values; otherwise, it is a scalar. If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses.

    Classes

    Functions

  • :param metrics: List of metrics to be evaluated by the model during training and testing. Each of this can be a string (name of a built-in function), function or a tf.keras.metrics.Metric instance. See tf.keras.metrics. Typically you will use metrics=['accuracy']. A function is any callable with the signature result = fn(y_true, y_pred). To specify different metrics for different outputs of a multi-output model, you could also pass a dictionary, such as metrics={'output_a': 'accuracy', 'output_b': ['accuracy', 'mse']}. You can also pass a list (len = len(outputs)) of lists of metrics such as metrics=[['accuracy'], ['accuracy', 'mse']] or metrics=['accuracy', ['accuracy', 'mse']]. When you pass the strings 'accuracy' or 'acc', we convert this to one of tf.keras.metrics.BinaryAccuracy, tf.keras.metrics.CategoricalAccuracy, tf.keras.metrics.SparseCategoricalAccuracy based on the loss function used and the model output shape. We do a similar conversion for the strings 'crossentropy' and 'ce' as well.

  • :param loss_weights: Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The loss value that will be minimized by the model will then be the weighted sum of all individual losses, weighted by the loss_weights coefficients. If a list, it is expected to have a 1:1 mapping to the model's outputs. If a dict, it is expected to map output names (strings) to scalar coefficients.
  • :param weighted_metrics: List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing.
  • :param run_eagerly: Bool. Defaults to False. If True, this Model's logic will not be wrapped in a tf.function. Recommended to leave this as None unless your Model cannot be run inside a tf.function.
  • :param steps_per_execution: Int. Defaults to 1. The number of batches to run during each tf.function call. Running multiple batches inside a single tf.function call can greatly improve performance on TPUs or small models with a large Python overhead. At most, one full epoch will be run each execution. If a number larger than the size of the epoch is passed, the execution will be truncated to the size of the epoch. Note that if steps_per_execution is set to N, Callback.on_batch_begin and Callback.on_batch_end methods will only be called every N batches (i.e. before/after each tf.function execution).
  • :param kwargs: Arguments supported for backwards compatibility only.

Raise

  • ValueError: In case of invalid arguments for optimizer, loss or metrics.
fit(self, *training_data, validation_data=None, epochs=3, callbacks=[], **kwargs)

Trains the model for a fixed number of epochs (iterations on a dataset).

Parameters

  • :param x: Input data. It could be:
    • A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs).
    • A TensorFlow tensor, or a list of tensors (in case the model has multiple inputs).
    • A dict mapping input names to the corresponding array/tensors, if the model has named inputs.
    • A tf.data dataset. Should return a tuple of either (inputs, targets) or (inputs, targets, sample_weights).
    • A generator or tf.keras.utils.Sequence returning (inputs, targets) or (inputs, targets, sample_weights). A more detailed description of unpacking behavior for iterator types (Dataset, generator, Sequence) is given below.
  • :param y: Target data. Like the input data x, it could be either Numpy array(s) or TensorFlow tensor(s). It should be consistent with x (you cannot have Numpy inputs and tensor targets, or inversely). If x is a dataset, generator, or keras.utils.Sequence instance, y should not be specified (since targets will be obtained from x).
predict(self, x, **kwargs)

Documentation here

evaluate(self, x=None, y=None, **kwargs)

Documentation here