Hi guys,

I got this type of error after running the function predict_and_sample.

I guess the problem with indices, but I’ve tried axis=0, -1, 1, 2, and all of theses got me an error.

I should mention that before this cell I have no error.

ValueError Traceback (most recent call last)

in

----> 1 results, indices = predict_and_sample(inference_model, x_initializer, a_initializer, c_initializer)

2

3 print(“np.argmax(results[12]) =”, np.argmax(results[12]))

4 print(“np.argmax(results[17]) =”, np.argmax(results[17]))

5 print(“list(indices[12:18]) =”, list(indices[12:18]))

in predict_and_sample(inference_model, x_initializer, a_initializer, c_initializer)

24 pred = inference_model.predict([x_initializer, a_initializer, c_initializer])

25 # Step 2: Convert “pred” into an np.array() of indices with the maximum probabilities

—> 26 indices = np.argmax(pred, axis=-1)

27 # Step 3: Convert indices to one-hot vectors, the shape of the results should be (1, )

28 results = to_categorical(indices, num_classes=n_values)

<**array_function** internals> in argmax(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in argmax(a, axis, out)

1184

1185 “”"

→ 1186 return _wrapfunc(a, ‘argmax’, axis=axis, out=out)

1187

1188

/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)

56 bound = getattr(obj, method, None)

57 if bound is None:

—> 58 return _wrapit(obj, method, *args, **kwds)

59

60 try:

/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)

45 except AttributeError:

46 wrap = None

—> 47 result = getattr(asarray(obj), method)(*args, **kwds)

48 if wrap:

49 if not isinstance(result, mu.ndarray):

**ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()**