Functions | |
main () | |
Main function that loads data and demonstrates basic tensor operations. | |
print_block_size (block_size, train_data) | |
Prints examples of context-target pairs for given block size. | |
train_val_split (data) | |
Splits data into training and validation sets. | |
get_batch (batch_size, block_size, split, train_data, val_data) | |
creates a training batch that can be stacked (better for gpus) | |
print_training_batch (input, targs, batch_size, block_size) | |
creates a training batch that can be stacked (better for gpus) | |
tensor_prac.Tensor_Prac.get_batch | ( | batch_size, | |
block_size, | |||
split, | |||
train_data, | |||
val_data ) |
creates a training batch that can be stacked (better for gpus)
When training data we can create a batch of block sizes to train on which is better for GPUs as they want to process multiple calcuations in one input
batch_size | the size of the batch (how many independent sequences will we process in parallel) |
block_size | the size of the context (what is the maximum context length for predictions) |
train_data | the Tensor that stores the data used to train |
val_data | the Tensor that stores the data used to validate |
Definition at line 110 of file Tensor_Prac.py.
Referenced by main().
tensor_prac.Tensor_Prac.main | ( | ) |
Main function that loads data and demonstrates basic tensor operations.
Opens a text file, processes the data, creates training/validation splits, and demonstrates block size operations.
Definition at line 17 of file Tensor_Prac.py.
References get_batch(), print_block_size(), print_training_batch(), and train_val_split().
tensor_prac.Tensor_Prac.print_block_size | ( | block_size, | |
train_data ) |
Prints examples of context-target pairs for given block size.
Demonstrates how the context window works by showing input-output pairs for different context lengths.
This function will be used to print the block size for the data. Another way to describe block size is the amount of context that we will look at for each pass for our model. So in this case the block_size could be variable but for this we will fix it to 8 for this practice model
block_size | the size of context we want to take in |
train_data | the training data we are using |
Definition at line 65 of file Tensor_Prac.py.
Referenced by main().
tensor_prac.Tensor_Prac.print_training_batch | ( | input, | |
targs, | |||
batch_size, | |||
block_size ) |
creates a training batch that can be stacked (better for gpus)
When training data we can create a batch of block sizes to train on which is better for GPUs as they want to process multiple calcuations in one input
input | the input batch tensor |
targs | the output batch tensor |
batch_size | the batch_size of our input tensors |
block_size | the batch_size of our model |
Definition at line 133 of file Tensor_Prac.py.
Referenced by main().
tensor_prac.Tensor_Prac.train_val_split | ( | data | ) |
Splits data into training and validation sets.
Creates a 90%/10% split between training and validation data.
data | Full dataset tensor |
Definition at line 94 of file Tensor_Prac.py.
Referenced by main().