gpt4 book ai didi

python - 语法错误 - 解析时出现意外的 EOF

转载 作者:太空宇宙 更新时间:2023-11-03 20:28:30 24 4
gpt4 key购买 nike

解析时出现意外的 EOF。我想不通。

outputs = []
for i in range (batch_size):

batch_state = np.zeros([1, hidden_layer], dtype=np.float32)
batch_output = np.zeros([1, hidden_layer], dtype=np.float32)

for ii in range (window_size):

batch_state, batch_output = LSTM_cell(tf.reshape(inputs[i]
[ii], (-1, 1)), batch_state, batch_output)

outputs.append(tf.matmul(batch_output, weights_output + bias_output_layer)

最佳答案

如果您修复缩进(仅在 for: 之后而不是之前缩进,始终使用相同的缩进(4 个空格)),请删除第 10/11 行中的换行符并添加另一个右括号最后一行,代码运行时没有解析或语法错误:

outputs = []
for i in range (batch_size):

batch_state = np.zeros([1, hidden_layer], dtype=np.float32)
batch_output = np.zeros([1, hidden_layer], dtype=np.float32)

for ii in range (window_size):

batch_state, batch_output = LSTM_cell(tf.reshape(inputs[i][ii], (-1, 1)), batch_state, batch_output)
outputs.append(tf.matmul(batch_output, weights_output + bias_output_layer))

当然它仍然不起作用,因为它使用了代码片段中 undefined variable 。

关于python - 语法错误 - 解析时出现意外的 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57659567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com