【发布时间】:2021-06-17 14:05:21
【问题描述】:
- 我正在使用 Jupyter notebook 编写 Python 并出现这种错误:
TypeError Traceback (most recent call last)
<ipython-input-11-3a2267df06a1> in <module>
1 # Section II: First run the backpropagation simulation
----> 2 model_s = vanilla_backpropagation()
TypeError: vanilla_backpropagation() missing 2 required positional arguments: 'X_train' and 'y_train'
- 当我尝试运行它时引起的:
# Section II: First run the backpropagation simulation
model_s = vanilla_backpropagation()
- 这里是 vanilla_backpropagation 函数和拆分训练测试的代码
def vanilla_backpropagation(X_train, y_train):
best_model = None
best_score = 100.00
for i in range(N):
model_s = build_ann(LOSS)
model_s.fit(X_train,
y_train,
epochs = STEPS,
batch_size = batch_size,
verbose = 0)
train_score = model_s.evaluate(X_train, y_train, batch_size = BATCH_SIZE, verbose = 0)
if train_score > best_score:
best_model = model_s
best_score = train_score
return best_model
if __name__ == "__main__":
# Section I: Build the data set
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2, shuffle = None)
谁能帮助解决这个错误?我坚持了好几天了。谢谢你
【问题讨论】:
-
您已经定义了一个名为
vanilla_backpropagation()的函数,它需要两个参数,但提供的参数为零。 -
其他东西 -
build_ann是什么?您需要确保代码对我们来说是 100% 可重现的(这样我们就可以将您提供的代码复制粘贴到我们的 ide 中,并得到完全相同的错误消息)。
标签: python training-data backpropagation