这个功能以前运行得很好,现在我看不出它出了什么问题。下面是按这个顺序排列的函数、错误和hypJson字典。即使我注释掉这个特定的部分,在执行相同任务的其他部分也会出现相同的错误。任何帮助都将不胜感激。谢谢!
for idx, row in dfT1.iterrows():
hypJson = json.loads(row['hyperparameters'])
if hypJson['dropout'] not in d1:
d1[hypJson['dropout']] = (row['test_accuracy'] * len(row['test_labels'], len(row['test_labels']))
t1count[hypJson['dropout']] = 1
else:
d1[hypJson['dropout']] = (d1[hypJson['dropout']][0] + row['test_accuracy'] * len(row['test_labels']), #correct
d1[hypJson['dropout']][1] + len(row['test_labels'])) #total
t1count[hypJson['dropout']] = t1count[hypJson['dropout']] + 1
File "<ipython-input-19-1326a1a48cb8>", line 11
t1count[hypJson['dropout']] = 1
^
SyntaxError: invalid syntax
{'dropout': 0, 'optimizer': 'sgd-001-0.9-nesterov', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
{'dropout': 0, 'optimizer': 'sgd-001-0.9', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
{'dropout': 0, 'optimizer': 'adam', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
{'dropout': 0.1, 'optimizer': 'sgd-001-0.9-nesterov', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
{'dropout': 0.1, 'optimizer': 'sgd-001-0.9', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
{'dropout': 0.1, 'optimizer': 'adam', 'deep-dense-top': False, 'convnet-freeze-percent': 0}
发布于 2020-06-30 20:34:29
上面的一行有不平衡的括号:
d1[hypJson['dropout']] = (row['test_accuracy'] * len(row['test_labels'], len(row['test_labels']))
^^^^ here它应该是:
d1[hypJson['dropout']] = (row['test_accuracy'] * len(row['test_labels']), len(row['test_labels']))Python通常会在语法错误后面的行上报告语法错误,因为缺少的结束括号本身并不是语法错误,所以它一直扫描代码,直到找到肯定是语法错误的东西,比如您的示例中的(...) t1count:
... = (row['test_accuracy'] * len(row['test_labels'], len(row['test_labels']))
t1count[hypJson['dropout']] = 1
^^^^^^^^ this is seen as (stuff)t1count, which is a syntax errorhttps://stackoverflow.com/questions/62665624
复制相似问题