NumSharp icon indicating copy to clipboard operation
NumSharp copied to clipboard

Numsharp0.30.0 np.random.choice() method missing cause Exception

Open UCtreespring opened this issue 4 years ago • 1 comments

System.NotSupportedException HResult=0x80131515 Source=NumSharp StackTrace: at NumSharp.NPTypeCodeExtensions.GetAccumulatingType(NPTypeCode typeCode) at NumSharp.Backends.DefaultEngine.cumsum_elementwise(NDArray& arr, Nullable1 typeCode) at NumSharp.Backends.DefaultEngine.ReduceCumAdd(NDArray& arr, Nullable1 axis_, Nullable`1 typeCode) at NumSharp.NumPyRandom.choice(Int32 a, Shape shape, Boolean replace, Double[] probabilities) at NumSharp.NumPyRandom.choice(NDArray arr, Shape shape, Boolean replace, Double[] probabilities) at PolicyGradient_TF050.PolicyGradient.ChooseAction(NDArray observation, NDArray actions, NDArray actionmask)

I‘m new to this ,

Thanks for help.

UCtreespring avatar Dec 14 '21 10:12 UCtreespring

This has been fixed. np.random.choice with probabilities now works correctly:

np.random.seed(42);
var probs = new double[] { 0.1, 0.2, 0.3, 0.4 };
var result = np.random.choice(4, 5, true, probs);
// Result: [2, 3, 3, 2, 1]

The underlying cumsum issue that caused the NotSupportedException has been resolved.

Resolved via #600, #602, #603, #596.

Nucs avatar Apr 12 '26 06:04 Nucs