Comments (7)
Sure, you can run the following code.
open Torch;;
let x = Tensor.of_float1 [| 5.5; 3. |];;
Tensor.print x;;
Fwiw for playing with the library I often use utop by just running dune utop
at the root of the github repo. You can then try various functions and have some nice code completion. You can also use the ocaml-jupyter kernel but it requires slightly more set up.
When writing code in an editor, merlin is a must have for completion, it allows you to easily discover the functions that you're looking for.
from ocaml-torch.
-
Thanks, code worked.
-
I have "dune utop" running, not at the top of the github repo, but in a separate directory with a dune file of
(executable
(name scratch)
(libraries base torch torch.core stdio))
-
dune top
is running inside tmux, which I can send commands to from Vim via vim-slime. -
I also have merlin/syntastic installed + working inside vim.
I definitely don't have a fluid workflow though. Here are issues I run into:
-
When I type in
Tensor.
and hit C-x C-o for auto complete, it returns for me 1014 auto completion results. Mentally, I'm looking for one titled "tensor" or "from_slice" -- not "of_float." Secondly, because there's "of_float0, of_float1, of_float2, of_float3", it looks like auto generated internal functions, not functions I should call. -
I'm not sure if this is a problem of merlin or VIM -- but in my auto completion, it only shows the function name, not the type signature -- which is unfortunate, as reading the type signature would help alot.
-
Of course, the type signature of tensor.ml functions are in tensor.mli, but I haven't quite figured outa fluid way to switch the two yet. There's ':MerlinTypeOf', but I haven't quite got a hang of it yet.
what would really help
Most of the time, I'd really like to be able to filter functions by type signature. So in this particular case, if I could say "list me all functions that take a float array
as one of it's arguments, and returns a Tensor as output" that would drastically narrow everything. I'm not sure existing tools allow me to do this.
from ocaml-torch.
Cool, you seem to already have a nice setup. I do get the types with merlin in vim and that's very helpful.
Re (5), there are some ocamldoc comments in src/torch/tensor.mli
that describe what of_floatX
is doing. I don't get them in merlin though, maybe it's possible to set this up.
from ocaml-torch.
I do get the types with merlin in vim and that's very helpful.
Interesting. Are you (1) getting this during auto completion, where it shows the type signature of each potential completion or (2) getting this outside of auto completion, when cursor is over some identifier / expr ?
I can achieve (2) via :MerlinTypeOf, but I can't figure out how to do (1).
from ocaml-torch.
I get both (1) and (2), (1) looks like the following for me. I don't remember having to do anything special to get this to work (and I also get the types when using the completion in jupyter notebooks).
from ocaml-torch.
Weird, I'm not getting type signatures yet. Will look into why.
from ocaml-torch.
It turns out "Tensor." C-x C-o => names, but no types
"Tensor.X" C-x C-o where X xis any char => names with types
So now (1) also "works" for me. Thanks!
from ocaml-torch.
Related Issues (20)
- Is it possible to download pretrained model weights from the python version of pytorch and use it in ocaml-torch? HOT 2
- Mnist example - crashes at runtime HOT 2
- Torch installation not working with ubuntu HOT 2
- Getting Issue with mnist tutorials HOT 5
- Is there anthing equivalent to load and save model in ocaml torch HOT 4
- Support for CUDA 11 HOT 3
- Mini-Dalle Example HOT 2
- How to load a npz file to a tensor? HOT 1
- diffusers-ocaml HOT 3
- Custom training HOT 1
- Setting slices of a tensor: what is the equivalent of (python) x[i,:,:] = y HOT 7
- debugging out-of-memory exception HOT 12
- Install Ocaml-Torch failed on macos with M1 chip HOT 2
- installing gpu accelerated version on macos
- most exceptions from libtorch not caught (macos) HOT 24
- installing on macos in presence of other pytorch instances HOT 11
- .pt file to .ot file - Anyway to skip the conversion HOT 12
- How to extend Tensor.t with additional functions? HOT 3
- Issues with install on MacOS, with ARM architecture
- undefined symbol: ffi_type_void, version LIBFFI_BASE_7.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml-torch.