简体   繁体   English

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

[英]How to understand a theano tensor as a matrix and a keras.backend variable?

If I am using Keras with theano, what is the difference between A and B in this case ? 如果我将Keras与theano一起使用,在这种情况下A和B有什么区别?

from keras import backend as K
import theano 

A = theano.tensor.matrix()
B =  K.zeros(shape = (d1, d2, d3, d4))

where d1-d4 are dimensions for example (1,4,14,14) 其中d1-d4是尺寸,例如(1,4,14,14)

According to the source code , keras creates this in theano: 根据源代码 ,keras在theano中创建了此代码

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

It's often better to use keras objects. 通常最好使用keras对象。 They've got shapes and other features for keras models. 他们具有用于keras模型的形状和其他功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM