How to use recent Tensorflow.JS? TF from deno.land/x/tensorflow@v0.21 appears to work, but it's old
I've only tried the TF package from deno.land/x/tensorflow@v0.21 with the readme page example. I'm hoping there are better options - read it as more recent and maintained ports of TF.
Here's the output of my trial of using jsdelivr version in Deno:
Would there be other options?
2 Replies
Based on the documentation, Deno has experimental support for npm specifiers, which allows you to import npm packages directly in your Deno scripts. However, this feature is still under development and might not work in all scenarios.
The error you're encountering seems to be related to the Tensorflow.js library itself when used in the Deno environment. It's possible that the library is trying to access some Node.js-specific APIs that are not available in Deno.
As of now, the documentation does not provide a clear solution for using the latest version of Tensorflow.js in Deno. You might want to consider using the version from deno.land/x/tensorflow@v0.21 if it works for your use case, even though it's not the latest version.
Alternatively, you could try using the
dnt
tool mentioned in the documentation to transform your Deno code into a Node.js compatible NPM package. This way, you could use the latest version of Tensorflow.js as you would in a Node.js environment. However, this might not be the ideal solution if you want to stick to Deno.
Remember to always use the --unstable
and --allow-net
flags when running your Deno script with npm specifiers, as they are required for this experimental feature.
Please note that this information is not explicitly stated in the documentation and is more of a general advice. 🦕Sorry I don't have any actual experience with Tensorflow, but the AI bot may be at the right tracks. Try using the actual NPM package (
import "npm:packagename"
). This activates Deno's Node compatibility layer, so you might have better luck with things working out of the box.