pytorch: grad can be implicitly created only for scalar outputs: z.backward(torch.ones_like(x)) 原因:backward必须使用标量来进行 0. python本身看起来数据类型不敏感,但是pytorch极其敏感,int与double不能直接相加,出现想干错误后应查看数据类型: print(tx.dtype) tx=tx.to(dtype=torch.float64) torch.nn.functional.Softmax …