I tried to predict using the predict function using the NN model created by keras, but I got the following error.
ValueError: Input 0 of layer dense is incompatible with the layer: expected axis -1 of input shape to have value 22 but received input with shape [None, 1]
I think this is because the model was trained with a multidimensional matrix of n rows x 22 columns, and this time it was an array of 1 row x 22 columns, but I couldn't think of a way to solve it.
Please let me know if there is any good solution.
train_input = [0.6571429 0. 0.11428571 0. 0.4857143 0.02857143 0.01428571 0.01428571 0. 0. 0. 0. 0.0. 0.01428571 0.08571429 0.15714286 0.01428571 0.04285714 0.6857143 1.] pred = model.predict (train_input)
What I tried
train =  train = np.append (train, train_input) pred = model.predict (train_input)
Answer # 1
If you replace "tried" with the following so that the shape of the train is (1,22), it will work.
For this kind of thing, it is good to try various functions of numpy's matrix stacking system while examining the shape. Surprisingly, np.empty can be used as the "initial value of stacking".
train = np.empty ((0, 22)) train = np.vstack ([train, train_input]) pred = model.predict (train)
If you just want to move, you can do the following.
pred = model.predict (np.array ([train_input]))
- python 3x - i want to get the nth array with an argument using python3 argparse
- python - i want to store a 3d array in an array using numpy
- i don't understand the exercises using python trigonometric functions
- python - read the multidimensional array saved by csv
- i want to manipulate the strings inside a python array
- python - typeerror when calculating the array of images called by imageopen ()
- about batch change of file name using python
- python - how to sort a 3d array
- python 3x - how to rename a folder created using jupyternotebook
- assign values to array arguments using variables
- python 3x - processing to jump to the link destination using chrome driver in python
- creating a two-dimensional array using malloc in c language
- python - error in image binarization using cv2adaptivethreshold function
- i want to adjust the execution result using the while statement in python as expected
- python - i want to delete non-multiples from the array string (sequence + \ n)
- python - i want to store an object in an array
- python - i want to put the image file path in a variable and open it using that variable
- python - aggregation processing using pandas
- specifying the range of the graph using python date