@qqqZXzz123

Как сделать чтобы нейросеть поняла входные данные?

Есть нейросеть
spoiler
Model: "model_2"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) [(None, 64, 64, 1)] 0 []
__________________________________________________________________________________________________
input_2 (InputLayer) [(None, 64, 64, 1)] 0 []
__________________________________________________________________________________________________
conv2d (Conv2D) (None, 64, 64, 32) 160 ['input_1[0][0]']
__________________________________________________________________________________________________
conv2d_3 (Conv2D) (None, 64, 64, 32) 160 ['input_2[0][0]']
__________________________________________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 32, 32, 32) 0 ['conv2d[0][0]']
__________________________________________________________________________________________________
max_pooling2d_3 (MaxPooling2D) (None, 32, 32, 32) 0 ['conv2d_3[0][0]']
__________________________________________________________________________________________________
conv2d_1 (Conv2D) (None, 32, 32, 64) 8256 ['max_pooling2d[0][0]']
__________________________________________________________________________________________________
conv2d_4 (Conv2D) (None, 32, 32, 64) 8256 ['max_pooling2d_3[0][0]']
__________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D) (None, 16, 16, 64) 0 ['conv2d_1[0][0]']
__________________________________________________________________________________________________
max_pooling2d_4 (MaxPooling2D) (None, 16, 16, 64) 0 ['conv2d_4[0][0]']
__________________________________________________________________________________________________
conv2d_2 (Conv2D) (None, 16, 16, 64) 16448 ['max_pooling2d_1[0][0]']
__________________________________________________________________________________________________
conv2d_5 (Conv2D) (None, 16, 16, 64) 16448 ['max_pooling2d_4[0][0]']
__________________________________________________________________________________________________
max_pooling2d_2 (MaxPooling2D) (None, 8, 8, 64) 0 ['conv2d_2[0][0]']
__________________________________________________________________________________________________
max_pooling2d_5 (MaxPooling2D) (None, 8, 8, 64) 0 ['conv2d_5[0][0]']
__________________________________________________________________________________________________
flatten (Flatten) (None, 4096) 0 ['max_pooling2d_2[0][0]']
__________________________________________________________________________________________________
flatten_1 (Flatten) (None, 4096) 0 ['max_pooling2d_5[0][0]']
__________________________________________________________________________________________________
dense (Dense) (None, 128) 524416 ['flatten[0][0]']
__________________________________________________________________________________________________
dense_1 (Dense) (None, 128) 524416 ['flatten_1[0][0]']
__________________________________________________________________________________________________
concatenate (Concatenate) (None, 256) 0 ['dense[0][0]',
'dense_1[0][0]']
__________________________________________________________________________________________________
dense_2 (Dense) (None, 256) 65792 ['concatenate[0][0]']
__________________________________________________________________________________________________
dense_3 (Dense) (None, 64) 16448 ['dense_2[0][0]']
__________________________________________________________________________________________________
dense_4 (Dense) (None, 3) 195 ['dense_3[0][0]']
__________________________________________________________________________________________________
dense_5 (Dense) (None, 3) 12 ['dense_4[0][0]']
==================================================================================================
Total params: 1,181,007
Trainable params: 1,181,007
Non-trainable params: 0
__________________________________________________________________________________________________

И ошибка которая возникает при подачи картики
spoiler
WARNING:tensorflow:Model was constructed with shape (None, 64, 64, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 64, 64, 1), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (32, 64).
WARNING:tensorflow:Model was constructed with shape (None, 64, 64, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 64, 64, 1), dtype=tf.float32, name='input_2'), name='input_2', description="created by layer 'input_2'"), but it was called on an input with incompatible shape (32, 64).

Traceback (most recent call last):
print(model.predict([image,image2]))

ValueError: Exception encountered when calling layer "model_2" (type Functional).

Input 0 of layer "conv2d_3" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received: (32, 64)

Call arguments received:
• inputs=('tf.Tensor(shape=(32, 64), dtype=float32)', 'tf.Tensor(shape=(32, 64), dtype=float32)')
• training=False
• mask=None

Картинка
spoiler

print(image.shape)
    print(len(image))
    print(type(image))
    print(image)


(64, 64)
64
class 'numpy.ndarray'
[[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]


У изображения разрешение 64x64 что с ним нужно сделать чтобы подать его на нейросеть?
  • Вопрос задан
  • 338 просмотров
Решения вопроса 1
wataru
@wataru
Разработчик на С++, экс-олимпиадник.
Вы сети скармливаете какие-то 2 картинки. У нее 2 input'а

print(model.predict([image,image2]))

Втавьте вот в этот код выше перед вызовом predict вывод размеров image и image2.

Сдается мне, что вы одну картинку как-то на 2 куска порезали и так и скормили сети. Если это не ваш код, то он возможно ожидает на вход картинку 128x64.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
22 нояб. 2024, в 02:56
10000 руб./за проект
22 нояб. 2024, в 00:55
500 руб./за проект
21 нояб. 2024, в 23:30
300000 руб./за проект