TypeError: Only HTTP(S) protocols are supported

6,714 views
Skip to first unread message

Loreto Parisi

unread,
Sep 28, 2018, 12:11:46 PM9/28/18
to TensorFlow.js Discussion
When running in Node.js this simple example

global.fetch = require('node-fetch');

require('@tensorflow/tfjs-node');
const tf = require('@tensorflow/tfjs');

let model_path = 'file://./model/nietzsche.json';
tf.loadModel(model_path)
.then(model => {
model.summary();
})
.catch(error => {
console.error(error)
})


my package.json is like

"dependencies": {
"@tensorflow/tfjs": "latest",
"@tensorflow/tfjs-core": "latest",
"@tensorflow/tfjs-node": "0.1.17",
"node-fetch": "^2.2.0"
}



Shanqing Cai

unread,
Sep 28, 2018, 12:17:29 PM9/28/18
to TensorFlow.js Discussion
Can you swap the order of the two lines, i.e.,

const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');

Also, remove the @tensorflow/tfjs and @tensorflow/tfjs-core dependencies from the package.json. Starting from tfjs-node 0.1.17,
those dependencies are included by default. Manually specifying those dependencies will lead to version mismatches and subtle
issues like this.

Loreto Parisi

unread,
Sep 28, 2018, 12:22:57 PM9/28/18
to TensorFlow.js Discussion
Hi Shanqing,
so I did

"dependencies": {
"@tensorflow/tfjs-node": "0.1.17",
"node-fetch": "^2.2.0"
}


removed package-lock and npm install again. I cannot see within node_modules/@tensorflow/ any other package than tfj-node. While within node_modules/@tensorflow/tfj-node/node_modules/@tensorflow there is everything. This causes a 

Error: Cannot find module '@tensorflow/tfjs'


error.

Shanqing Cai

unread,
Sep 28, 2018, 12:26:58 PM9/28/18
to loreto...@gmail.com, TensorFlow.js Discussion
That's weird. Can you remove the entire node_modules folder and try again?

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/fb9390ae-07b0-4e20-bfe7-002bcd7a1d44%40tensorflow.org.


--
---
Shanqing Cai
Software Engineer
Google

Loreto Parisi

unread,
Sep 28, 2018, 12:30:16 PM9/28/18
to TensorFlow.js Discussion, loreto...@gmail.com
You were right, that was the issue, some node cache issues!, thanks now it loads the model

ip-192-168-22-127:lstm-text-generator loretoparisi$ node index.js 

2018-09-28 18:28:45.819026: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA

(node:23580) Warning: N-API is an experimental feature and could change at any time.

Orthogonal initializer is being called on a matrix with more than 2000 (65536) elements: Slowness may result.

_________________________________________________________________

Layer (type)                 Output shape              Param #   

=================================================================

lstm_LSTM1 (LSTM)            [null,128]                109056    

_________________________________________________________________

dense_Dense1 (Dense)         [null,84]                 10836     

=================================================================

Total params: 119892

Trainable params: 119892

Non-trainable params: 0

_________________________________________________________________

ip-192-168-22-127:lstm-text-generator loretoparisi$ 


Test here: I have put the example here https://github.com/loretoparisi/tensorflow-node-examples/blob/master/lstm-text-generator/index.js
Reply all
Reply to author
Forward
0 new messages