Python 如何将theano张量理解为矩阵和keras.backend变量?

Python 如何将theano张量理解为矩阵和keras.backend变量?,python,keras,theano,tensor,Python,Keras,Theano,Tensor,如果我将Keras与theano一起使用,在这种情况下,A和B之间的区别是什么 from keras import backend as K import theano A = theano.tensor.matrix() B = K.zeros(shape = (d1, d2, d3, d4)) 其中,d1-d4是尺寸,例如(1,4,14,14)根据,keras在编号中创建: variable = theano.shared(value=np.zeros(shape),

如果我将Keras与theano一起使用,在这种情况下,A和B之间的区别是什么

from keras import backend as K
import theano 

A = theano.tensor.matrix()
B =  K.zeros(shape = (d1, d2, d3, d4))
其中,d1-d4是尺寸,例如(1,4,14,14)

根据,keras在编号中创建:

variable = theano.shared(value=np.zeros(shape),
                         name='somename',
                         strict=False)
variable._keras_shape = value.shape
variable._uses_learning_phase = False

使用keras对象通常更好。他们为keras模型提供了形状和其他功能

好的!因此,在我的自定义层中,我可以使用ano.tensor.matrix()初始化新的张量,并在不丢失层与反向传播之间的连接的情况下操作它们吗?换句话说,我可以使用K.variable来操作自定义层中的数据吗?我问的原因是在您在第197行共享的链接中:,它说用K.variable()创建的变量“不是”keras张量-这在反向传播过程中如何影响我的学习过程?通常可以(在自定义层和lambda层内)使用theano函数,一切都会很好。这很有帮助。非常感谢。