We Are Going To Discuss About ValueError: cannot reshape array of size 3 into shape (1,80). So lets Start this Python Article.
ValueError: cannot reshape array of size 3 into shape (1,80)
- How to solve ValueError: cannot reshape array of size 3 into shape (1,80)
try the following with the two different values for
n
:import numpy as np n = 10160 #n = 10083 X = np.arange(n).reshape(1,-1) np.shape(X) X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:10080,:] X_train_2 = X[:,10080:10160,:].reshape(1,80) np.shape(X_train_2)
If you cannot make sure thatX
is 10160 long I suggest one of the following solutions:X_train_1
with 10080 samples,X_train_2
with the rest:X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:10080,:] # X_train_1 with 10080 samples X_train_2 = X[:,10080:,:].reshape(1,-1) # X_train_2 with the remaining samples
OrX_train_2
with 80 samples,X_train_1
with the rest:X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:-80,:] # X_train_1 with the remaining samples X_train_2 = X[:,-80:,:].reshape(1,80) # X_train_2 with 80 samples
- ValueError: cannot reshape array of size 3 into shape (1,80)
try the following with the two different values for
n
:import numpy as np n = 10160 #n = 10083 X = np.arange(n).reshape(1,-1) np.shape(X) X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:10080,:] X_train_2 = X[:,10080:10160,:].reshape(1,80) np.shape(X_train_2)
If you cannot make sure thatX
is 10160 long I suggest one of the following solutions:X_train_1
with 10080 samples,X_train_2
with the rest:X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:10080,:] # X_train_1 with 10080 samples X_train_2 = X[:,10080:,:].reshape(1,-1) # X_train_2 with the remaining samples
OrX_train_2
with 80 samples,X_train_1
with the rest:X = X.reshape([X.shape[0], X.shape[1],1]) X_train_1 = X[:,0:-80,:] # X_train_1 with the remaining samples X_train_2 = X[:,-80:,:].reshape(1,80) # X_train_2 with 80 samples
Solution 1
try the following with the two different values for n
:
import numpy as np
n = 10160
#n = 10083
X = np.arange(n).reshape(1,-1)
np.shape(X)
X = X.reshape([X.shape[0], X.shape[1],1])
X_train_1 = X[:,0:10080,:]
X_train_2 = X[:,10080:10160,:].reshape(1,80)
np.shape(X_train_2)
If you cannot make sure that X
is 10160 long I suggest one of the following solutions:
X_train_1
with 10080 samples, X_train_2
with the rest:
X = X.reshape([X.shape[0], X.shape[1],1])
X_train_1 = X[:,0:10080,:] # X_train_1 with 10080 samples
X_train_2 = X[:,10080:,:].reshape(1,-1) # X_train_2 with the remaining samples
Or X_train_2
with 80 samples, X_train_1
with the rest:
X = X.reshape([X.shape[0], X.shape[1],1])
X_train_1 = X[:,0:-80,:] # X_train_1 with the remaining samples
X_train_2 = X[:,-80:,:].reshape(1,80) # X_train_2 with 80 samples
Original Author konstanze Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.