SciSharp / NumSharp

High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
https://github.com/SciSharp
Apache License 2.0
1.34k stars 188 forks source link

Unable to use np.dot due to "Specified method unsupported" error #446

Open Bartechnika opened 3 years ago

Bartechnika commented 3 years ago

I have recently been working on a unity project involving the genetic algorithm, but have run into an error while trying to use the function np.dot(). NumSharp has been installed using the NuGet client NuGetForUnity

The error message is as follows:

NotSupportedException: Specified method is not supported. NumSharp.NPTypeCodeExtensions.GetAccumulatingType (NumSharp.NPTypeCode typeCode) (at <7807b007e09c46aca587061f8867e538>:0) NumSharp.Backends.DefaultEngine.ReduceAdd (NumSharp.NDArray& arr, System.Nullable1[T] axis_, System.Boolean keepdims, System.Nullable1[T] typeCode, NumSharp.NDArray out) (at <7807b007e09c46aca587061f8867e538>:0) NumSharp.Backends.DefaultEngine.Sum (NumSharp.NDArray& nd, System.Nullable1[T] axis, System.Nullable1[T] typeCode, System.Boolean keepdims) (at <7807b007e09c46aca587061f8867e538>:0) NumSharp.np.sum (NumSharp.NDArray& a, System.Int32 axis) (at <7807b007e09c46aca587061f8867e538>:0) NumSharp.Backends.DefaultEngine.Dot (NumSharp.NDArray& left, NumSharp.NDArray& right) (at <7807b007e09c46aca587061f8867e538>:0) NumSharp.np.dot (NumSharp.NDArray& a, NumSharp.NDArray& b) (at <7807b007e09c46aca587061f8867e538>:0) NN.FeedForward () (at Assets/scripts/NeuralNetwork.cs:73) Bot.FixedUpdate () (at Assets/scripts/Bot.cs:70)

Line 73 of the FeedForward script:

  1. NDArray activations = np.dot(layers[i].weights, layers[i].activations);

Other sections of relevant code:

  1. layer.weights = np.random.rand(3, 2);
  2. layer.activations = np.zeros(2);
Nucs commented 3 years ago

Related to #447

BlackholeGH commented 3 years ago

I seem to have this same issue, in a similar context attempting to use np.dot to do a dot-product for two 1-D numpy arrays containing double values. Assuming we're not both doing something wrong, any workarounds beside calculating the dot product manually?

System.NotSupportedException HResult=0x80131515 Message=Specified method is not supported. Source=NumSharp StackTrace: at NumSharp.NPTypeCodeExtensions.GetAccumulatingType(NPTypeCode typeCode) at NumSharp.Backends.DefaultEngine.sumelementwise(NDArray arr, Nullable1 typeCode) at NumSharp.Backends.DefaultEngine.ReduceAdd(NDArray& arr, Nullable1 axis, Boolean keepdims, Nullable`1 typeCode, NDArray out) at NumSharp.Backends.DefaultEngine.Dot(NDArray& left, NDArray& right)

Bartechnika commented 3 years ago

I seem to have this same issue, in a similar context attempting to use np.dot to do a dot-product for two 1-D numpy arrays containing double values. Assuming we're not both doing something wrong, any workarounds beside calculating the dot product manually?

System.NotSupportedException HResult=0x80131515 Message=Specified method is not supported. Source=NumSharp StackTrace: at NumSharp.NPTypeCodeExtensions.GetAccumulatingType(NPTypeCode typeCode) at NumSharp.Backends.DefaultEngine.sumelementwise(NDArray arr, Nullable1 typeCode) at NumSharp.Backends.DefaultEngine.ReduceAdd(NDArray& arr, Nullable1 axis, Boolean keepdims, Nullable`1 typeCode, NDArray out) at NumSharp.Backends.DefaultEngine.Dot(NDArray& left, NDArray& right)

Hello, thankyou for commenting on this issue. No workarounds as far as I am aware, I ended up having to scrap part of my project sadly. Thanks anyway.