You can convert your list to a numpy array and then reshape it with numpy.reshape
import numpy as np
# Convert to numpy array
w_train = np.array(w_train)
w_test = np.array(w_train)
# Reshape
w_train = np.reshape(w_train, (2404,28,224,224,3))
w_test = np.reshape(w_test, (601,28,224,224,3))
Answer from MD Mushfirat Mohaimin on Stack OverflowYou can convert your list to a numpy array and then reshape it with numpy.reshape
import numpy as np
# Convert to numpy array
w_train = np.array(w_train)
w_test = np.array(w_train)
# Reshape
w_train = np.reshape(w_train, (2404,28,224,224,3))
w_test = np.reshape(w_test, (601,28,224,224,3))
reshape is a methode under numpy's library and as the error printed in your terminal the object list has no methode defined as reshape
import numpy as np
w_train=np.array(x_train)
then you can simply use the reshape function without any error :
w_train=x_train.reshape((2404,28,224,224,3))
you can check the reshape characteristics in this link for more understanding of the methode
python - AttributeError: 'list' object has no attribute 'reshape' - Stack Overflow
Seeing AttributeError: 'Dataset' object has no attribute 'reshape' when using "dataset.get_nearest_examples"
"AttributeError: 'list' object has no attribute 'reshape'" when use OpenGL renderer to transform a math LaTeX formula to another
BUG: Series has no attribute "reshape" after adding a new category in df
I got this warning:
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. A = np.array([[56.0, 0.0, 4,4, 68.0],
And according to this question: numpy.VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
This has to do with the creation of arrays from lists of unequal length. So I presume that in this line:
[56.0, 0.0, 4,4, 68.0]
The 4,4 should have been a 4.4, right?
You first list has one more item (5 vs 4 for the others). This makes it an object array with python lists as elements (and you get a VisibleDeprecationWarning warning).
Thus cal becomes a concatenation of the lists ([56.0, 0.0, 4, 4, 68.0, 1.2, 104.0, 52.0, 8.0, 1.8, 135.0, 99.0, 0.9]) instead of a numpy array, triggering your error.
I imagine this might be a typo and changing 4,4 to 4.4 gives the following output:
A = np.array([[56.0, 0.0, 4.4, 68.0],
[1.2, 104.0, 52.0, 8.0],
[1.8, 135.0, 99.0, 0.9],])
cal = A.sum(axis=0)
# array([ 59. , 239. , 155.4, 76.9])
percentage = 100*A/cal.reshape(1,4)
print(percentage)
output:
[[94.91525424 0. 2.83140283 88.42652796]
[ 2.03389831 43.51464435 33.46203346 10.40312094]
[ 3.05084746 56.48535565 63.70656371 1.17035111]]
I try to face swap using ace++ workflow, but this error shows up - 'NoneType' object has no attribute 'reshape'.
This is workflow.
https://drive.google.com/file/d/1dCWpJFvieTGgpHnw7wd0KF69qtAs3ONo/view?usp=sharing
Use numpy.array to use shape attribute.
>>> import numpy as np
>>> X = np.array([
... [[-9.035250067710876], [7.453250169754028], [33.34074878692627]],
... [[-6.63700008392334], [5.132999956607819], [31.66075038909912]],
... [[-5.1272499561309814], [8.251499891281128], [30.925999641418457]]
... ])
>>> X.shape
(3L, 3L, 1L)
NOTE X.shape returns 3-items tuple for the given array; [n, T] = X.shape raises ValueError.
Alternatively, you can use np.shape(...)
For instance:
import numpy as np
a=[1,2,3]
and np.shape(a) will give an output of (3,)
Solution was linked on reshaped method on documentation page.
Insted of Y.reshape(-1,1) you need to use:
Y.values.reshape(-1,1)
The solution is indeed to do:
Y.values.reshape(-1,1)
This extracts a numpy array with the values of your pandas Series object and then reshapes it to a 2D array.
The reason you need to do this is that pandas Series objects are by design one dimensional. Another solution if you would like to stay within the pandas library would be to convert the Series to a DataFrame which would then be 2D:
Y = pd.Series([1,2,3,1,2,3,4,32,2,3,42,3])
scaler = StandardScaler()
Ys = scaler.fit_transform(pd.DataFrame(Y))