feat: CNN model start + rude concept of training
This commit is contained in:
parent
d6c8bf4a13
commit
947aba31ee
6 changed files with 383 additions and 1 deletions
11
CNN-model/data_utils.py
Normal file
11
CNN-model/data_utils.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import torch
|
||||
from torch.utils.data import TensorDataset
|
||||
|
||||
|
||||
def make_context_pairs(data: bytes, context_length: int) -> TensorDataset:
|
||||
data = torch.tensor(data, dtype=torch.uint8)
|
||||
sample_count = data.shape[0] - context_length
|
||||
x = data.unfold(0, context_length, 1)[:sample_count]
|
||||
y = data[context_length:]
|
||||
return TensorDataset(x, y)
|
||||
|
||||
Reference in a new issue