which is provided implicitly by the call. As in Smalltalk, classes themselves are objects, albeit in the wider sense of the word: in Python, all data types are objects. This provides semantics for importing and renaming. Unlike C++ and Modula-3, built-in types can be used as base classes...
RuntimeError: grad can be implicitly created only for scalar outputs 問(wèn)題分析: 因?yàn)槲覀冊(cè)趫?zhí)行 loss.backward() 時(shí)沒帶參數(shù),這與 loss.backward(torch.Tensor(1.0)) 是相同的,參數(shù)默認(rèn)就是一個(gè)標(biāo)量。 但是由于自己的loss不是一個(gè)標(biāo)量,而是二維的張量,所以就會(huì)報(bào)錯(cuò)。