-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there interest to make TorchSharp for user friendly with e.g. .NET Interactive? #297
Comments
@GeorgeS2019 -- if I understand your request, it's that you want a better 'ToString()' for TorchTensor, right? [BTW, I added convenience overloads for 'rand' that takes the rows and columns, so you don't have to construct an array. Not sure whether that's in the latest NuGet or not, but it's coming.] |
Tensorflow.NET is setup to be as close to python code as possible in different environment e.g. SciSharpCube (.NET jupyter). The motivation is that eventually it is possible to use a pythonToCsharp converter to port e.g. pyTorch code to TorchSharp in almost similar code layout in high percentage. |
torch.normal(mean=0.5, std=torch.arange(0.2,0.6)) Torch.Arange seems to take only Integer parameters. Please correct me if I am wrong :-) |
FYI all sample codes come from |
The Python version of arange() takes all kinds of numbers. See: https://pytorch.org/docs/stable/generated/torch.arange.html?highlight=arange#torch.arange |
Working on a better ToString() would be interesting. I'm personally partial to how Julia prints tensors with more than two dimensions:
I like that the indices are printed (Julia is a column-major language, so the indices would be in the first dimensions rather than the last in .NET.) @dsyme -- you probably have thoughts on this topic. |
I'm proposing a second ToString() overload defined on TorchTensor: public string ToString(bool withData, string fltFormat = "g5", int width = 100) The boolean is there to distinguish from the overriden ToString(), and is not necessary if the method is called something else. One could also define it as: public new string ToString(bool withData = false, string fltFormat = "g5", int width = 100) to hide the overridden method. Anyway, it would produce output like this:
In this case, by passing in "0.0000000" as the format string. The width parameter is there to prevent the method from making up extremely long lines. Instead, when the width is reached, each row ends with '...' |
FYI more time needed to load LibTorch CPU and GPU |
@NiklasGustafsson I like all your proposals here |
@GeorgeS2019 -- it will currently adhere to the current locale as far as comma vs. period. It'll impact the unit tests, but apart from that, it seems to me the right behavior. |
Combined pull requests 301 and 302 in Visual Studio Code .NET Interactive! |
Currently, there is no friendly print function when using TorchSharp in e.g. .NET Interactive , or I could have miss it?
The text was updated successfully, but these errors were encountered: