Traceback (most recent call last):
File "C:\Users\Designer5.PUCCINI.000\Documents\simple ai frfr\main.py", line 36, in
print(model.predict(np.array(state)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Designer5.PUCCINI.000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\keras\src\utils\traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\Designer5.PUCCINI.000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\keras\src\models\functional.py", line 264, in _adjust_input_rank
raise ValueError(
ValueError: Exception encountered when calling Sequential.call().
Invalid input shape for input Tensor("sequential_1/Cast:0", shape=(5,), dtype=float32). Expected shape (None, 5), but input has incompatible shape (5,)
Arguments received by Sequential.call():
• inputs=tf.Tensor(shape=(5,), dtype=int32)
• training=False
• mask=None
Пожалуйста, помогите. Tensorflow очень раздражает, и мне нужно это исправить, пожалуйста. Вот ошибка: [code]Traceback (most recent call last): File "C:\Users\Designer5.PUCCINI.000\Documents\simple ai frfr\main.py", line 36, in print(model.predict(np.array(state))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Designer5.PUCCINI.000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\keras\src\utils\traceback_utils.py", line 122, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\Designer5.PUCCINI.000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\keras\src\models\functional.py", line 264, in _adjust_input_rank raise ValueError( ValueError: Exception encountered when calling Sequential.call().
Invalid input shape for input Tensor("sequential_1/Cast:0", shape=(5,), dtype=float32). Expected shape (None, 5), but input has incompatible shape (5,)
Arguments received by Sequential.call(): • inputs=tf.Tensor(shape=(5,), dtype=int32) • training=False • mask=None [/code] и вот код, который пошёл не так [code] ans = model.predict(np.array(state))[0] ans_index = ans.index(max(ans)) if ans_index == 0 and state == [1, 0, 0, 0, 0]: break elif ans_index == 2 and state == [0, 0, 0, 0, 1]: break
if ans_index == 0: one_pos -= 1
if ans_index == 2: one_pos += 1
if ans_index == 1: if state.index(1) < 2: one_pos -= 1 elif state.index(1) > 2: one_pos += 1
state = [1 if one_pos == 0 else 0, 1 if one_pos == 1 else 0, 1 if one_pos == 2 else 0, 1 if one_pos == 3 else 0, 1 if one_pos == 4 else 0, 1 if one_pos == 5 else 0] print(state) [/code] Спасибо