theano编程中,判断数据为空时很烦人的事,
theano.Tensor.lmatrix ,numpy.array , list 为空的判断方法
T.lmatrix有shape属性, numpy.array有shape属性,list没有shape属性。
只有将list强制转为array,方法为:sa = numpy.array(value)
这样sa.shape会是(x,)。
通过这样的转换,三个类型都有shape属性。可以用shape判断为空。
本文探讨了Theano编程中判断数据是否为空的方法,重点介绍了如何利用Theano的Tensor.lmatrix、numpy.array以及list的不同特性来进行空值判断,并提供了一种通用的解决方案。
theano编程中,判断数据为空时很烦人的事,
theano.Tensor.lmatrix ,numpy.array , list 为空的判断方法
T.lmatrix有shape属性, numpy.array有shape属性,list没有shape属性。
只有将list强制转为array,方法为:sa = numpy.array(value)
这样sa.shape会是(x,)。
通过这样的转换,三个类型都有shape属性。可以用shape判断为空。
411
9107

被折叠的 条评论
为什么被折叠?