SciSharp / SciSharp-Stack-Examples

Practical examples written in SciSharp's machine learning libraries
http://scisharpstack.org
Apache License 2.0
313 stars 100 forks source link

The type 'Tensor' does not define the field, constructor or member 'asTensor'. #58

Closed manpil closed 2 years ago

manpil commented 2 years ago

As I was trying to reproduce the fully connected keras example in F# i encountered the following error: The type 'Tensor' does not define the field, constructor or member 'asTensor'. Has anyone an idea why?

issue
Oceania2018 commented 2 years ago

Is the x_train NDArray? if yes, you can use tf.constant(x_train) to convert it as tensor.

manpil commented 2 years ago

Not quite, but thanks for the push in the right direction. I now figured it out. x_train was already a tensor, y_train was an NDArray. Another problem was the .asTensors method as seen in this screenshot image I used Tensors.op_Implicit inputs to convert Tensors to Tensor and vice verca. Should I close the issue or open a pull request with the changes? I am not sure if I fully understand the repo yet or if I just forgot to include other important files

Oceania2018 commented 2 years ago

If you make it work, you can PR the fix.

manpil commented 2 years ago

Nevermind, I was missing an important file for it to build. The code works as it is. I am closing the issue. Thank you for your help.

dedale commented 2 years ago

@Oceania2018 @manpil not sure if this relates to the examples I ported to F#. C# code and samples make great use of automatic type convertors which are not implicitly available in F#. That's why I added many extra type methods to simplify the code.

Cf. https://github.com/SciSharp/SciSharp-Stack-Examples/blob/0872fdf1d2ba4755709fd2f6a1cb01b5a8872a04/src/TensorFlowNET.Examples.FSharp/Operators.fs