How to get the batch size inside lambda layer
问题 I'm trying to implement a layer (via lambda layer) which is doing the following numpy procedure: def func(x, n): return np.concatenate((x[:, :n], np.tile(x[:, n:].mean(axis = 0), (x.shape[0], 1))), axis = 1) I'm stuck because I don't know how to get the size of the first dimension of x (which is the batch size). The backend function int_shape(x) returns (None, ...) . So, if I know the batch_size, the corresponding Keras procedure would be: def func(x, n): return K.concatenate([x[:, :n], K