- This topic has 1 reply, 2 voices, and was last updated 5 years, 2 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forums › Fórum Deep Learning de A à Z com PyTorch e Python › Treinamento do Modelo
Na parte 1 – Redes neurais artificiais: Classificação binária – base breast cancer na etapa de Treinamento do Modelo, fiz o seguinte código, conforme proposto na aula:
for epoch in range(100):
running_loss = 0.
for data in train_loader:
inputs, labels = data
optimizer.zero_grad()
outputs = classificador(inputs)
Entretanto, acontece o seguinte erro no google collab:
—————————————————————————
RuntimeError Traceback (most recent call last)
<ipython-input-58-cb716bf3324b> in <module>()
6 optimizer.zero_grad()
7
—-> 8 outputs = classificador.forward(inputs)
9 print(outputs)
10
3 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in linear(input, weight, bias)
1368 if input.dim() == 2 and bias is not None:
1369 # fused op is marginally faster
-> 1370 ret = torch.addmm(bias, input, weight.t())
1371 else:
1372 output = input.matmul(weight.t())
RuntimeError: size mismatch, m1: [10 x 16], m2: [30 x 16] at /pytorch/aten/src/TH/generic/THTensorMath.cpp:136
Como eu poderia fazer pra resolver?
Olá Felipe,
Deve haver algum erro na criação da rede, pois a mensagem de erro aponta incompatibilidade no tamanho das camadas ocultas.
Verifique o código correspondente e, se continuar tendo erro, por favor reproduza seu código aqui.