How to use tensorflow js (tfjs) from typescript?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I've tried to install typings:



npm install --save @type/tfjs
npm install --save @type/tenforflowjs
npm install --save @type/tensorflow


But it doesn't exist. On tensorflow js github repository I can see that it is developed using Typescript, but it seems they did not distribute definitions. If there is no definition distribution (I hope I am wrong), how can I use their github repository to obtain it and still benefit from their future releases?










share|improve this question























  • npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

    – Explosion Pills
    Nov 16 '18 at 16:38











  • @ExplosionPills it worked, thank you. You should put it as the answer.

    – ozgur
    Nov 16 '18 at 16:49




















2















I've tried to install typings:



npm install --save @type/tfjs
npm install --save @type/tenforflowjs
npm install --save @type/tensorflow


But it doesn't exist. On tensorflow js github repository I can see that it is developed using Typescript, but it seems they did not distribute definitions. If there is no definition distribution (I hope I am wrong), how can I use their github repository to obtain it and still benefit from their future releases?










share|improve this question























  • npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

    – Explosion Pills
    Nov 16 '18 at 16:38











  • @ExplosionPills it worked, thank you. You should put it as the answer.

    – ozgur
    Nov 16 '18 at 16:49
















2












2








2








I've tried to install typings:



npm install --save @type/tfjs
npm install --save @type/tenforflowjs
npm install --save @type/tensorflow


But it doesn't exist. On tensorflow js github repository I can see that it is developed using Typescript, but it seems they did not distribute definitions. If there is no definition distribution (I hope I am wrong), how can I use their github repository to obtain it and still benefit from their future releases?










share|improve this question














I've tried to install typings:



npm install --save @type/tfjs
npm install --save @type/tenforflowjs
npm install --save @type/tensorflow


But it doesn't exist. On tensorflow js github repository I can see that it is developed using Typescript, but it seems they did not distribute definitions. If there is no definition distribution (I hope I am wrong), how can I use their github repository to obtain it and still benefit from their future releases?







typescript typescript-typings tensorflow.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 16:34









ozgurozgur

9081824




9081824













  • npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

    – Explosion Pills
    Nov 16 '18 at 16:38











  • @ExplosionPills it worked, thank you. You should put it as the answer.

    – ozgur
    Nov 16 '18 at 16:49





















  • npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

    – Explosion Pills
    Nov 16 '18 at 16:38











  • @ExplosionPills it worked, thank you. You should put it as the answer.

    – ozgur
    Nov 16 '18 at 16:49



















npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

– Explosion Pills
Nov 16 '18 at 16:38





npm install --save @tensorflow/tfjs should be all you need. The type definitions are included.

– Explosion Pills
Nov 16 '18 at 16:38













@ExplosionPills it worked, thank you. You should put it as the answer.

– ozgur
Nov 16 '18 at 16:49







@ExplosionPills it worked, thank you. You should put it as the answer.

– ozgur
Nov 16 '18 at 16:49














1 Answer
1






active

oldest

votes


















1














Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.



If you do npm install --save @tensorflow/tfjs, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts. Additionally in the package.json for the project, there is "types": "dist/index.d.ts".



That is to say types are available for this library.



If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}. Otherwise you'll be on your own for strong typing.






share|improve this answer
























  • But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

    – Kokodoko
    Mar 29 at 20:54











  • I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

    – Kokodoko
    Mar 29 at 23:21











  • If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

    – Explosion Pills
    Mar 29 at 23:38











  • True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

    – Kokodoko
    Mar 30 at 14:13














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341962%2fhow-to-use-tensorflow-js-tfjs-from-typescript%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.



If you do npm install --save @tensorflow/tfjs, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts. Additionally in the package.json for the project, there is "types": "dist/index.d.ts".



That is to say types are available for this library.



If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}. Otherwise you'll be on your own for strong typing.






share|improve this answer
























  • But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

    – Kokodoko
    Mar 29 at 20:54











  • I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

    – Kokodoko
    Mar 29 at 23:21











  • If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

    – Explosion Pills
    Mar 29 at 23:38











  • True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

    – Kokodoko
    Mar 30 at 14:13


















1














Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.



If you do npm install --save @tensorflow/tfjs, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts. Additionally in the package.json for the project, there is "types": "dist/index.d.ts".



That is to say types are available for this library.



If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}. Otherwise you'll be on your own for strong typing.






share|improve this answer
























  • But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

    – Kokodoko
    Mar 29 at 20:54











  • I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

    – Kokodoko
    Mar 29 at 23:21











  • If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

    – Explosion Pills
    Mar 29 at 23:38











  • True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

    – Kokodoko
    Mar 30 at 14:13
















1












1








1







Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.



If you do npm install --save @tensorflow/tfjs, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts. Additionally in the package.json for the project, there is "types": "dist/index.d.ts".



That is to say types are available for this library.



If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}. Otherwise you'll be on your own for strong typing.






share|improve this answer













Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.



If you do npm install --save @tensorflow/tfjs, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts. Additionally in the package.json for the project, there is "types": "dist/index.d.ts".



That is to say types are available for this library.



If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}. Otherwise you'll be on your own for strong typing.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 17:10









Explosion PillsExplosion Pills

152k38230318




152k38230318













  • But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

    – Kokodoko
    Mar 29 at 20:54











  • I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

    – Kokodoko
    Mar 29 at 23:21











  • If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

    – Explosion Pills
    Mar 29 at 23:38











  • True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

    – Kokodoko
    Mar 30 at 14:13





















  • But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

    – Kokodoko
    Mar 29 at 20:54











  • I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

    – Kokodoko
    Mar 29 at 23:21











  • If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

    – Explosion Pills
    Mar 29 at 23:38











  • True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

    – Kokodoko
    Mar 30 at 14:13



















But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

– Kokodoko
Mar 29 at 20:54





But that .d.ts file only links to several other .d.ts files. There are more than 10 .d.ts files in the whole node_modules folder. Are they all needed if you want to work with typescript?

– Kokodoko
Mar 29 at 20:54













I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

– Kokodoko
Mar 29 at 23:21





I guess you need to build the project, and then a single .d.ts file is generated in the dist folder?

– Kokodoko
Mar 29 at 23:21













If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

– Explosion Pills
Mar 29 at 23:38





If you import from @tensorflow/tfjs it should use the .d.ts files that are there as well. This shouldn't require any additional setup.

– Explosion Pills
Mar 29 at 23:38













True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

– Kokodoko
Mar 30 at 14:13







True! But then you need the whole node_modules folder. I would prefer a single .d.ts file, just to get typescript intellisense for Tensorflow. I still load tensorflow itself using the script tag, without using a module build process.

– Kokodoko
Mar 30 at 14:13






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341962%2fhow-to-use-tensorflow-js-tfjs-from-typescript%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python