0

RuntimeError Traceback (most recent call last) /tmp/ipykernel_77/2707828773.py in <cell line: 8>() 30 #反向传播 31 optimizer.zero_grad() ---> 32 loss.backward() 33 optimizer.step() 34

~/.conda/envs/default/lib/python3.9/site-packages/torch/_tensor.py in backward(self, gradient, retain_graph, create_graph, inputs) 486 inputs=inputs, 487 ) --> 488 torch.autograd.backward( 489 self, gradient, retain_graph, create_graph, inputs=inputs 490 )

~/.conda/envs/default/lib/python3.9/site-packages/torch/autograd/init.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables, inputs) 195 # some Python versions print out the first line of a multi-line function 196 # calls in the traceback and some print out the last line --> 197 Variable.execution_engine.run_backward( # Calls into the C++ engine to run the backward pass 198 tensors, grad_tensors, retain_graph, create_graph, inputs, 199 allow_unreachable=True, accumulate_grad=True) # Calls into the C++ engine to run the backward pass

my code is edited by SageMaker Studio Lab. i dont know what happen. how can i fix this error?

0 Answers0