import numpy as np
import keras
from keras import backend as K
# In Numpy
data = np.array([[[1,2,3], [4,5,6]]])
data.shape
(1,2,3)
data[:,-1,:].shape
(1,3)
# In Keras with MXNet backend
var1 = K.variable(data)
var1.shape
(1,2,3)
K.eval(var1[:,-1,:])
<<ERROR>>
Check failed: b < e (1 vs. 0) slicing with begin=[1]=1, end[1]=0, and step[1]=1 is invalid
Reason:
MXNet does not support slicing the axis with mx.sym.slice operator.
In KerasSymbol, getitem method, we need to special case this kind of slicing and use mx.sym.slice_axis()
Minimum reproducible code:
Reason:
MXNet does not support slicing the axis with mx.sym.slice operator. In KerasSymbol, getitem method, we need to special case this kind of slicing and use mx.sym.slice_axis()