credit.replay_buffer#
Classes#
Base class for all neural network modules. |
|
Helper class that provides a standard way to create an ABC using |
Functions#
Module Contents#
- credit.replay_buffer.cleanup()#
- credit.replay_buffer.cycle(dl)#
- credit.replay_buffer.accum_log(log, new_logs)#
- class credit.replay_buffer.WeightedRMSE(conf)#
Bases:
torch.nn.ModuleBase class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will also have their parameters converted when you call
to(), etc.Note
As per the example above, an
__init__()call to the parent class must be made before assignment on the child.- Variables:
training (bool) – Boolean represents whether this module is in training or evaluation mode.
- lat_weights = None#
- forward(predictions, targets)#
- class credit.replay_buffer.ReplayBuffer(conf, buffer_size=32, device='cpu', dtype=np.float32, rank=0)#
- buffer_size = 32#
- ptr = 0#
- size = 0#
- dtype#
- device = 'cpu'#
- rank = 0#
- input_shape#
- forecast_hour#
- index#
- q_values#
- rmse_scores#
- dataset#
- numpy_dir#
- metric_fn#
- add(x, lookup_key)#
Add new experience to the buffer.
- sample(batch_size, epsilon=0.2)#
Sample a batch of experiences from the buffer, increment forecast_hour, and update x with new predictions.
- update_q_values(indices, y_predict, y_truth)#
- update(indices, new_x, new_lookup_key)#
Update existing data in the buffer.
- update_with_predictions(model, sample_size, epsilon=0.2)#
Use stored predictions as inputs for future predictions.
- concat_and_reshape(x1, x2)#
- load_inputs(idx)#
- populate()#
Populate the buffer with random data points from the dataset.
- save()#
Save the forecast hours, index arrays, pointer, size, Q-values, and RMSE scores to disk.
- reload()#
Reload the buffer from saved numpy files.
- class credit.replay_buffer.Trainer(model: torch.nn.Module, rank: int, conf: Dict[str, Any])#
Bases:
credit.trainers.base_trainer.BaseTrainerHelper class that provides a standard way to create an ABC using inheritance.
- train_one_epoch(epoch, conf, trainloader, optimizer, criterion, scaler, scheduler, metrics)#