Tensorflow JS universal sentence encoder in webworker

Viewed 63

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

1 Answers

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

Related