# Create a DataLoader for the validation set
valid_dl = learn.dls.test_dl(X_val, y_val)
# Get predictions and interpret them on the validation set
interp = ClassificationInterpretation.from_learner(learn, dl=valid_dl)
У меня есть следующая модель. Это хорошо тренируется. Формы моих разделений: [list] [*]X_train (98, 1, 40, 844) [*]X_val (21, 1, 40, 844) [*]X_test (21, 1, 40, 844) [/list] Однако я получаю следующую ошибку при x = F.relu(self.fc1(x)) в прямом направлении. Когда я пытаюсь интерпретировать модель в наборе проверки. [code]# Create a DataLoader for the validation set valid_dl = learn.dls.test_dl(X_val, y_val)
# Get predictions and interpret them on the validation set interp = ClassificationInterpretation.from_learner(learn, dl=valid_dl) [/code] [code]RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x2110 and 67520x128)[/code] Я проверил десятки подобных вопросов, но не смог найти решения. Вот код. [code]from fastai.vision.all import * import librosa import numpy as np from sklearn.model_selection import train_test_split import torch import torch.nn as nn from torchsummary import summary
[...] #labels in y can be [0,1,2,3]
# Split the data X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.3, random_state=42) X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42)
def forward(self, x): x = self.pool(F.relu(self.conv1(x))) x = self.pool(F.relu(self.conv2(x))) x = x.view(x.size(0), -1) # Flatten the output of convolutions x = F.relu(self.fc1(x)) x = self.fc2(x) return x
# Initialize the model and the Learner model = AudioCNN() learn = Learner(dls, model, loss_func=CrossEntropyLossFlat(), metrics=[accuracy, Precision(average='macro'), Recall(average='macro'), F1Score(average='macro')])
# Train the model learn.fit_one_cycle(8)
print(summary(model, (1, 40, 844)))
# Create a DataLoader for the validation set valid_dl = learn.dls.test_dl(X_val, y_val)
# Get predictions and interpret them on the validation set interp = ClassificationInterpretation.from_learner(learn, dl=valid_dl) interp.plot_confusion_matrix() interp.plot_top_losses(5) [/code] Я пробовал изменить функцию пересылки и форму слоев, но все равно получаю ту же ошибку. Изменить. По запросу я добавил больше кода.
I have just started doing Vision Transformer from scratch using pytorch. And the I got error like this when I run the training helper code. I know it is about the shape is not match, but I don't know which one I should do. The code is like this :...
Я выбиваю модель NN в качестве новички на Pytorch и получаю следующее сообщение об ошибке, когда моя модель делает вызов в функцию встраивания факела:
Traceback (most recent call last):
File...
Недавно я пытался заставить агента понга с использованием обучения подкреплению, но я продолжаю получать ошибки, независимо от того, что я делаю. Реализация PPO, которую я использую, была первоначально разработана для Cartpole, и я изменил его для...
Недавно я пытался заставить агента понга с использованием обучения подкреплению, но я продолжаю получать ошибки, независимо от того, что я делаю. Реализация PPO, которую я использую, была первоначально разработана для Cartpole, и я изменил его для...