Error code:
new_x = 84610
pre_y = model.predict(new_x)
print(pre_y)
Error result:
ValueError: Expected 2D array, got scalar array instead:
array=84610.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Solution:
Reshape data using array
Reshape data using array
Reshape data using array If the data has a single function or array, resize the shape (-1, 1). If the data contains a single example, resize the shape (1, -1).
Solution:
add
new_x = np.array(new_x).reshape(1, -1)
Modified code:
new_x = 84610
new_x = np.array(new_x).reshape(1, -1)
pre_y = model.predict(new_x)
print(pre_y)
Reproduced in: https://www.cnblogs.com/hankleo/p/11310272.html
Read More:
- Array of PHP_ diff,array_ intersect,array_ merge, in_ Is there a limit on the number of arrays in array?
- [Solved] RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1‘
- ValueError: need at least one array to concatenate
- Python3-ValueError:not enough values to unpack (expected 2, got 0)
- ValueError: not enough values to unpack (expected 2, got 0)
- ValueError: not enough values to unpack (expected 6, got 1)
- Variable type error: error of array occurs when TP5 controller receives the array of post
- Tensorflow ValueError: Failed to convert a NumPy array to a Tensor
- Two dimensional array and pointer to one dimensional array
- ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256,
- Error occurred when Python called cv2.findcontours: valueerror: not enough values to unpack (expected 3, got 2)
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- Error: improvement of not enough values to unpack (expected 2, got 1)
- [Python] numpy library array splicing np.concatenate Detailed explanation and examples of official documents
- JavaScript removes the number specified in the array
- How to use C + + function pointer array
- RuntimeError: expected scalar type Double but found Float
- Solve the runtimeerror in RNN: expected scalar type long but found float error
- Exception jsonmappingexception: out of start_ ARRAY token
- Implement Set using Array.