ValueError: cannot reshape array of size 3 into shape (1,80)

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)

Advertisements
  1. 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 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

  2. 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 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

Solution 1

Advertisements

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

Advertisements

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Advertisements
ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment