import numpy as np
a=np.random.randn(1, 2)
b=np.zeros((1,2))
print("Data type of A: ",type(a))
print("Data type of A: ",type(b))
输出:
Data type of A: <class 'numpy.ndarray'>
Data type of A: <class 'numpy.ndarray'>
在np.zeros()中,我们在2个括号中给出输入来声明一个数组,而在np.random.radn()中,我们在1个括号中给出输入?
这种语法有没有特别的原因,因为它们都是相同的数据类型,但是遵循不同的语法?
np.reshape
需要形状元组,而x.reshape(...)
接受扩展元组(2,3)
和((2,3))
的问题类似。https://stackoverflow.com/questions/46508340/passing-new-shape-to-np-reshape - hpaulj