Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
255 views
in Technique[技术] by (71.8m points)

web worker - Tensorflow JS universal sentence encoder in webworker

I am running USE in webworker and it is running fine. I am trying to pass model to webworker. The reason behind this is that each time a webworker runs it downloads a new model. While passing model in post message following error is displayed:

Failed to execute 'postMessage' on 'Worker': function t(t,n){return e.apply(this,arguments)} could not be cloned.

Tried to serialize the model and pass it but model has circular dependency so it cannot be serialized.

Is there any alternate method to pass model to web worker?

The goal behind passing model is to improve the execution time of the embed function of the USE

question from:https://stackoverflow.com/questions/65843033/tensorflow-js-universal-sentence-encoder-in-webworker

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A model cannot be passed between workers because a model object cannot be serialized and only serialized object are allowed as messages according to the documentation.

Models need not to be pass between workers instances. The model output and input can however being exchanged between the workers


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...