How to convert kerasSymbol to ndarray?

I am trying to convert my networks in keras (tensorflow backend) to mxnet backend.

What confused me is when I use gluon.utils.metrics.segmentation.batch_intersection_union to calculate MIoU in the Semantic Segmentation task as follow:

def MIoU(y_true, y_pred, nb_classes= args.nb_classes):
      area_inter, area_union = batch_intersection_union(y_pred, y_true, nclass= nb_classes)
      miou = K.cast(area_inter / area_union, dtype=np.float32)
      return K.cast(miou/nb_classes, dtype=np.float32)

the error is:

AttributeError: ‘KerasSymbol’ object has no attribute ‘asnumpy’ .

What does it means and how to solve this problem?
Any help would be appreciated. Thanks in advance.

Hi @MariosOreo,

Are you using Keras-MXNet to switch the backend of your keras program, or are you trying to rewrite your code in MXNet? Would you be able to include a minimal verifiable example if you’re re-writing in MXNet/Gluon?

Vishaal