We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the Training cell I am getting this error
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (3 x 3). Kernel size can't be greater than actual input size
model, loss_fn, optimizer = get_model() accuracies, losses =[], [] epochs = 5 for epoch in range(epochs): epoch_losses, epoch_accuracies = [], [] for ix, batch in enumerate(iter(trn_dl)): x, y = batch loss = train_batch(x, y, model, loss_fn, optimizer) epoch_losses.append(loss) epoch_loss = np.array(epoch_losses).mean() # accuracy check for ix, batch in enumerate(iter(trn_dl)): x, y = batch acc = accuracy_fn(x, y, model) epoch_accuracies.append(acc) epoch_acc = np.mean(epoch_accuracies) accuracies.append(epoch_acc) losses.append(epoch_loss)
# defining the CNN architecture def get_model(): model = nn.Sequential( nn.Conv2d(1, 64, kernel_size=3), nn.MaxPool2d(2), nn.ReLU(), nn.Conv2d(64, 128, kernel_size=3), nn.MaxPool2d(2), nn.ReLU(), nn.Flatten(), nn.Linear(3200, 256), nn.ReLU(), nn.Linear(256, 10) ).to(device) loss_fn = nn.CrossEntropyLoss() optimizer = Adam(model.parameters(), lr=1e-3) return model, loss_fn, optimizer
# creating a training function def train_batch(x, y, model, loss_fn, opt): model.train() prediction = model(x) batch_loss = loss_fn(prediction, y) batch_loss.backward() opt.zero_grad() opt.step() return batch_loss.item() @torch.no_grad() def accuracy_fn(x, y, model): model.eval() prediction = model(x) max_val, argmaxes = prediction.max(-1) is_correct = argmaxes == y is_correct = is_correct.cpu().numpy().tolist() return is_correct
I have no idea what must have gone.. I Think the images was reduced to size smaller for the filter with 3x3. How do i fix this?
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
No branches or pull requests
In the Training cell I am getting this error
Training
CNN model architecture
The Training and Accuracy functions
I have no idea what must have gone.. I Think the images was reduced to size smaller for the filter with 3x3. How do i fix this?
The text was updated successfully, but these errors were encountered: