theano reshape -1

来源:互联网 发布:儿歌软件哪个好 编辑:程序博客网 时间:2024/06/04 19:44
import theanoimport numpy as npones = theano.shared(np.float32([[1,2,3],[4,5,6],[7,8,9]]))print(ones.get_value())print(ones.reshape([1,-1]).eval())print(ones.reshape((1,-1)).eval())print(ones.reshape((-1,)).eval())print(ones.reshape((-1,1)).eval())# print(ones.reshape((2,-1)).eval()) # ValueError: Cannot reshape input of shape (3, 3) to shape [ 2 -1]

结果

[[ 1. 2. 3.]
[ 4. 5. 6.]
[ 7. 8. 9.]]

[[ 1. 2. 3. 4. 5. 6. 7. 8. 9.]]

[[ 1. 2. 3. 4. 5. 6. 7. 8. 9.]]

[ 1. 2. 3. 4. 5. 6. 7. 8. 9.]

[[ 1.]
[ 2.]
[ 3.]
[ 4.]
[ 5.]
[ 6.]
[ 7.]
[ 8.]
[ 9.]]

0 0
原创粉丝点击