简体   繁体   中英

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 ?

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)

According to the source code , keras creates this in 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. They've got shapes and other features for keras models.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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