ResNet1DInterface
- class ketos.neural_networks.resnet.ResNet1DInterface(block_sets=[2, 2, 2], n_classes=2, initial_filters=2, initial_strides=1, initial_kernel=30, strides=2, kernel=300, optimizer=Adam ketos recipe, loss_function=CategoricalCrossentropy ketos recipe, metrics=[CategoricalAccuracy ketos recipe, Precision ketos recipe, Recall ketos recipe])[source]
Methods
transform_batch
(x, y[, n_classes])Transforms a training batch into the format expected by the network.
Attributes
checkpoint_dir
early_stopping_monitor
Sets an early stopping monitor.
log_dir
test_generator
train_generator
val_generator
valid_losses
valid_metrics
valid_optimizers
- classmethod transform_batch(x, y, n_classes=2)[source]
Transforms a training batch into the format expected by the network.
When this interface is subclassed to make new neural_network classes, this method can be overwritten to accomodate any transformations required. Common operations are reshaping of input arrays and parsing or one hot encoding of the labels.
- Args:
- x:numpy.array
The batch of inputs with shape (batch_size, width, height)
- y:numpy.array
The batch of labels. Each label must be represented as an integer, ranging from zero to n_classes The array is expected to have a field named ‘label’.
- n_classes:int
The number of possible classes for one hot encoding.
- Returns:
- X:numpy.array
The transformed batch of inputs
- Y:numpy.array
The transformed batch of labels
- Examples:
>>> import numpy as np >>> # Create a batch of 10 5x5 arrays >>> inputs = np.random.rand(10,5,5) >>> inputs.shape (10, 5, 5)
>>> # Create a batch of 10 labels (0 or 1) >>> labels = np.random.choice([0,1], size=10) >>> labels.shape (10,)
>>> transformed_inputs, transformed_labels = NNInterface.transform_batch(inputs, labels, n_classes=2) >>> transformed_inputs.shape (10, 5, 5, 1)
>>> transformed_labels.shape (10, 2)