numpy.hstack((a,b))与numpy.vstack((a,b))
合并数组
hstack在列上合并,vstack在行上合并。
>>> a = np.ones((2,2))
>>> b = np.eye(2)
>>> print np.vstack((a,b))
[[ 1. 1.]
[ 1. 1.]
[ 1. 0.]
[ 0. 1.]]
>>> print np.hstack((a,b))
[[ 1. 1. 1. 0.]
[ 1. 1. 0. 1.]]
test3=numpy.array([[1],[2],[3]])
#test3.shape
#(3, 1)
test4=numpy.array([[5],[6],[7]])
#test4.shape
#(3, 1)
test5=numpy.hstack((test3,test4))
test5
>>> array([[1, 5],
[2, 6],
[3, 7]])
#test5.shape
#(3, 2)
test5=numpy.vstack((test3,test4))
test5
>>> array([[1],
[2],
[3],
[5],
[6],
[7]])
#test5.shape
#(6, 1)
numpy.tile(a,b)
重复a,b次,这里的b可以时int类型也可以是元组类型。
>>> import numpy
>>> numpy.tile([0,0],5)#在列方向上重复[0,0]5次,默认行1次
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
>>> numpy.tile([0,0],(1,1))#在列方向上重复[0,0]1次,行1次
array([[0, 0]])
>>> numpy.tile([0,0],(2,1))#在列方向上重复[0,0]1次,行2次
array([[0, 0],
[0, 0]])
>>> numpy.tile([0,0],(3,1))
array([[0, 0],
[0, 0],
[0, 0]])
>>> numpy.tile([0,0],(1,3))#在列方向上重复[0,0]3次,行1次
array([[0, 0, 0, 0, 0, 0]])
>>> numpy.tile([0,0],(2,3))<span style="font-family: Arial, Helvetica, sans-serif;">#在列方向上重复[0,0]3次,行2次</span>
array([[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]])
keras.layers.core.Dense()
全连接层