[英]NameError: global name 'interfaceName' is not defined even though it is
[英]name 'net_input' is not defined even though it is in global
我將net_input
聲明為全局變量,但仍然出現NameError: name 'net_input' is not defined
global net_input
noise = net_input.detach().clone()
錯誤行是:
net_input_saved = net_input.detach().clone()
錯誤
NameError:未定義名稱“ net_input”
首先,您需要定義變量,然后使其成為全局變量以在整個程序中使用。
net_input = "some object" # assume this is an object and defined somewhere else in your program
global net_input # make sure that net_input is defined prior
noise = net_input.detach().clone()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.