鉴于以下内容......
C:\Projects\caffe\include\caffe/test/test_gradient_check_util.hpp(175): error: The difference between computed_gradient and estimated_gradient is 1.5981258813447825, which exceeds threshold_ * scale, where
computed_gradient evaluates to 2.755687472811343,
estimated_gradient evaluates to 1.1575615914665605, and
threshold_ * scale evaluates to 0.027556874728113429.
debug: (top_id, top_data_id, blob_id, feat_id)=0,0,1,49; feat = 1.5097962694948988; objective+ = 20.508002455868997; objective- = 20.484851224039666
[ FAILED ] ImgdistLossLayerTest/3.TestGradient, where TypeParam = struct caffe::GPUDevice<double> (204 ms)
[----------] 2 tests from ImgdistLossLayerTest/3 (222 ms total)
[----------] Global test environment tear-down
[==========] 8 tests from 4 test cases ran. (878 ms total)
[ PASSED ] 4 tests.
[ FAILED ] 4 tests, listed below:
[ FAILED ] ImgdistLossLayerTest/0.TestGradient, where TypeParam = struct caffe::CPUDevice<float>
[ FAILED ] ImgdistLossLayerTest/1.TestGradient, where TypeParam = struct caffe::CPUDevice<double>
[ FAILED ] ImgdistLossLayerTest/2.TestGradient, where TypeParam = struct caffe::GPUDevice<float>
[ FAILED ] ImgdistLossLayerTest/3.TestGradient, where TypeParam = struct caffe::GPUDevice<double>
4 FAILED TESTS
为什么python会出现def foo(bar):
return bar * 2
class FOO:
BAR = 2
a = foo(BAR)
class FAZ:
a = foo(BAR)
错误?我的期望是,如果允许NameError: name 'BAR' is not defined
并允许类引用其范围之外的东西,它会起作用。
foo(BAR)
此限制是否存在技术原因?一个设计?
是否有解决方法(除了在课堂外移动$ python foo.py
Traceback (most recent call last):
File "foo.py", line 6, in <module>
class FOO:
File "foo.py", line 10, in FOO
class FAZ:
File "foo.py", line 11, in FAZ
a = foo(BAR)
NameError: name 'BAR' is not defined
)?即,
BAR
编辑:
关注duplicate的链接的任何人:
乍一看,问题有些不同 - 在python2中工作,而不是在python3中,并且是关于列表推导的。然而,接受的答案似乎也涵盖了我的问题。