运行深度学习代码是出现问题

Traceback (most recent call last):

 File "<input>", line 1, in <module>

 File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile

  pydev_imports.execfile(filename, global_vars, local_vars) # execute the script

 File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile

  exec(compile(contents+"\n", file, 'exec'), glob, loc)

 File "/Users/onereoublic/Downloads/Wireless_Scheduling-master/Evaluate/evaluate_sumrate.py", line 45, in <module>

  allocs_all_methods["Deep Learning"] = Deep_Learning_Scheduling.sumRate_scheduling(general_para, layouts)

 File "/Users/onereoublic/Downloads/Wireless_Scheduling-master/Neural_Network_Model/Deep_Learning_Scheduling.py", line 18, in sumRate_scheduling

  neural_net.build_network()

 File "/Users/onereoublic/Downloads/Wireless_Scheduling-master/Neural_Network_Model/Convolutional_Neural_Network_Model.py", line 131, in build_network

  self.prepare_parameters() # set up parameters to be reused in iteration_step function call

 File "/Users/onereoublic/Downloads/Wireless_Scheduling-master/Neural_Network_Model/Convolutional_Neural_Network_Model.py", line 52, in prepare_parameters

  with tf.compat.v1.get_variable_scope("fc_lyr1"):

TypeError: get_variable_scope() takes 0 positional arguments but 1 was given



get_variable_scope()不需要参数
tf.compat.v1.get_variable_scope()


在你的这个文档Convolutional_Neural_Network_Model.py", 第 52行的代码:with tf.compat.v1.get_variable_scope("fc_lyr1"):

调用这个方法的时候传入的一个参数,但是创建的get_variable_scope()方法是没有传参的,所以报错了。

@杨凤霞 您好意思是这段代码有问题吗?我是应该把它修改还是怎么说?

意思是如果你要传入参数的话你就要找到创建get_variable_scope()第地方,也要有一个形参,才能传进去;前提是get_variable_scope()是你自己写的函数,如果是python中自带的,那你就在调用的时候不能把"fc_lyr1"传进去哟