-1

I got a weird object that shows like this...

type(l.sum())
l.sum()

This is what it outputs:

<class 'mxnet.ndarray.ndarray.NDArray'>
[83.32651]
<NDArray 1 @cpu(0)>

I want to convert it to a scalar but no matter how I try it stays as array.

l.sum()[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]

Still outputs:

[83.32651]
<NDArray 1 @cpu(0)>
Anonymous
  • 4,692
  • 8
  • 61
  • 91

1 Answers1

0

For some unknown reasons probably the misbehavior is caused by sum().

Converting to numpy before the operation has solved the problem:

l.asnumpy().sum()

This returns a scalar as expected.

Anonymous
  • 4,692
  • 8
  • 61
  • 91