I have the following code which uses keras and it raises:
AttributeError: 'Tensor' object has no attribute 'shape'
The code:
def call( self, tx_and_ty, mask = None ) :
tx, ty = tx_and_ty
n_samples, n_chs, n_rows, n_cols = tx.get_shape()
n_pixs = n_rows * n_cols
txf = tx.reshape( ( n_samples, n_chs, n_pixs ) ).dimshuffle( 0, 2, 1 ) # ( n_samples, n_pixs, n_chs )
tyf = ty.reshape( ( n_samples, n_chs, n_pixs ) ) / n_chs # ( n_samples, n_chs, n_pixs )
res = tt.batched_dot( txf, tyf ) # ( n_samples, n_pixs, n_pixs )
resf = res.flatten( 2 ).dimshuffle( 1, 0 )
resm = resf[ self.midx ].dimshuffle( 1, 0 ).reshape( [n_samples, n_pixs, n_rows, n_cols] )
return tt.cast( resm, 'float32' )
Could anyone please tell me what I am missing?