Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,7 +67,7 @@ class MemoryEfficientNN(nn.Module):
|
|
67 |
class MemoryEfficientDataset(IterableDataset):
|
68 |
def __init__(self, X, y, batch_size):
|
69 |
self.X = X
|
70 |
-
self.y = torch.LongTensor(y) # Convert labels to long tensors
|
71 |
self.batch_size = batch_size
|
72 |
|
73 |
def __iter__(self):
|
@@ -75,7 +75,6 @@ class MemoryEfficientDataset(IterableDataset):
|
|
75 |
X_batch = self.X[i:i+self.batch_size].toarray()
|
76 |
y_batch = self.y[i:i+self.batch_size]
|
77 |
yield torch.FloatTensor(X_batch), y_batch
|
78 |
-
|
79 |
# Train Memory-Efficient Neural Network
|
80 |
X_train, X_test, y_train, y_test = train_test_split(contexts_encoded, emotions_target, test_size=0.2, random_state=42)
|
81 |
input_size = X_train.shape[1]
|
|
|
67 |
class MemoryEfficientDataset(IterableDataset):
|
68 |
def __init__(self, X, y, batch_size):
|
69 |
self.X = X
|
70 |
+
self.y = torch.LongTensor(y.unsqueeze(1)) # Convert labels to long tensors and add a new dimension
|
71 |
self.batch_size = batch_size
|
72 |
|
73 |
def __iter__(self):
|
|
|
75 |
X_batch = self.X[i:i+self.batch_size].toarray()
|
76 |
y_batch = self.y[i:i+self.batch_size]
|
77 |
yield torch.FloatTensor(X_batch), y_batch
|
|
|
78 |
# Train Memory-Efficient Neural Network
|
79 |
X_train, X_test, y_train, y_test = train_test_split(contexts_encoded, emotions_target, test_size=0.2, random_state=42)
|
80 |
input_size = X_train.shape[1]
|