Я загрузил файл .h5 с GitHub и хотел сделать из него прогнозы. Я выполнил следующий код:
from keras.models import load_model
from PIL import Image
import numpy as np
im = Image.open('img.jpg')
img = np.array(im)
model = load_model('model_weight.h5')
a = model.predict(img)
print(a)
и получил следующую ошибку:
ValueError: Input 0 of layer dense_1 is incompatible with the layer: expected axis -1 of input shape to have value 4096 but received input with shape [None, 300, 3]
Вот сводка модели:
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) [(None, 4096)] 0
__________________________________________________________________________________________________
input_2 (InputLayer) [(None, 34)] 0
__________________________________________________________________________________________________
dropout_1 (Dropout) (None, 4096) 0 input_1[0][0]
__________________________________________________________________________________________________
embedding_1 (Embedding) (None, 34, 256) 1940224 input_2[0][0]
__________________________________________________________________________________________________
dense_1 (Dense) (None, 128) 524416 dropout_1[0][0]
__________________________________________________________________________________________________
lstm_1 (LSTM) (None, 34, 256) 525312 embedding_1[0][0]
__________________________________________________________________________________________________
repeat_vector_1 (RepeatVector) (None, 34, 128) 0 dense_1[0][0]
__________________________________________________________________________________________________
time_distributed_1 (TimeDistrib (None, 34, 128) 32896 lstm_1[0][0]
__________________________________________________________________________________________________
concatenate_1 (Concatenate) (None, 34, 256) 0 repeat_vector_1[0][0]
time_distributed_1[0][0]
__________________________________________________________________________________________________
lstm_2 (LSTM) (None, 1000) 5028000 concatenate_1[0][0]
__________________________________________________________________________________________________
dense_3 (Dense) (None, 7579) 7586579 lstm_2[0][0]
==================================================================================================
Total params: 15,637,427
Trainable params: 15,637,427
Non-trainable params: 0
__________________________________________________________________________________________________
WARNING:tensorflow:Model was constructed with shape (None, 4096) for input Tensor("input_1:0", shape=(None, 4096), dtype=float32), but it was called on an input with incompatible shape (None, 300, 3).
Я знаю, что у меня есть чтобы изменить его, но не знаю, как это сделать. Любая помощь будет принята с благодарностью.
Спасибо