According to the Keras manual,
keras.backend.shape() returns the symbolic shape of a tensor or variable. keras.backend.int_shape() returns the shape of tensor or variable as a tuple of int or None entries.
These definitions are still unclear to me. I couldn't find any relevant material in Google, either. Can anyone help me understand the difference between the two?
import keras.backend as K
import numpy as np
x = K.variable(np.eye(2, 2))
print('shape:', K.shape(x))
print('int_shape:', K.int_shape(x))
gives
shape: Tensor("Shape_4:0", shape=(2,), dtype=int32)
int_shape: (2, 2)
As you can see, first one is a tensor (it contains two numbers of corresponding shape) whereas the second one is a tuple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With