I trained a deep-learning model with python using Tensorflow library, and I saved it in pickle file.
My question- Is there a way to extract this file with firebase cloud functions via node.js runtime?
thanks.
There has been an official javascript version of tensorflow released some weeks ago.
With tfjs-converter it is possible to convert pretrained models to javascript.
Check out https://github.com/tensorflow/tfjs-converter and https://js.tensorflow.org/
Related
In the latest version of the Anomaly Detection Service by Azure which supports the Multi-variate Cognitive Service, we need to train a model and then consume it.
The quickstart documentation for Python mentions a few libraries which are not getting imported:
from azure.ai.anomalydetector.models import DetectionRequest, ModelInfo
Both these libraries are throwing import errors.
How can we use the Multivariate Anomaly Detection Service using the Python SDK?
This error was with version azure-ai-anomalydetector==3.0.0b2. With version azure-ai-anomalydetector==3.0.0b3, this has been addressed.
The problem is because of the change of the response format recently. To solve that issue, you can change the line with error to
model_status = self.ad_client.get_multivariate_model(trained_model_id).model_info.status
I have a python script which I wrote using tensorflow python 3.6 AWS sagemaker jupyter notebook inside AWS sagemaker instance. I have to use sagemaker debugger for my Deep Learning model. I can see many links suggesting that first dockerise the algorithm image and then use it over sagemaker. Can anyone please suggest that is there any available alternative such that Tensorflow-1 docker image is available and I can include some other packages via pip in this image and then run my model on sagemaker ? I am using keras 2.3.0 with tensorflow 1.15 .Please guide and share necessary references.
You don't have to dockerize your code yourself, you can use an existing SageMaker TensorFlow image, and with the SageMaker Python SDK you can let SageMaker manipulate docker images for you - no docker knowledge needed ! This documentation explains how to launch your own TF code on SageMaker Training or SageMaker Hosting. You can add a requirements.txt file to bring extra dependencies
I am using the SentenceTransformers library (here: https://pypi.org/project/sentence-transformers/#pretrained-models) for creating embeddings of sentences using the pretrained model bert-base-nli-mean-tokens. I have an application that will be deployed to a device that does not have internet access. How can I save this model locally so that when I call it, it loads the model locally, rather than attempting to download from the internet? As the library maintainers make clear, the method SentenceTransformer downloads the model from the internet (see here: https://pypi.org/project/sentence-transformers/#pretrained-models) and I cannot find a method for saving the model locally.
Hugging face usage
You can download the models locally by using the Hugging Face transformer library method.
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/bert-base-nli-mean-tokens")
model = AutoModel.from_pretrained("sentence-transformers/bert-base-nli-mean-tokens")
tokenizer.save_pretrained('./local_directory/')
model.save_pretrained('./local_directory/')
After instantiating the SentenceTransformer via download, you can then save it to any path of your choosing with the 'save()' method.
model = SentenceTransformer('distilbert-base-nli-stsb-mean-tokens')
model.save('/my/local/directory/for/models/')
The accepted answer doesn't work, as it doesn't have the encapsulating folder and config.json that SentenceTransformer is looking for
I have been trying to import a model from onnx format to work with pytorch. I am finding it difficult to get an example for the same. As most of the resources in Internet talks about exporting a pytorch model to onnx.
I found that torch.onnx() can only export the model and the import method hasn't been implemented yet. A direct installation of onnx library, helps me to do onnx.load("model_name.onnx"). How do I use this model with pytorch? I am not able to move the model to GPU with model.to(device="GPU")
PyTorch doesn't currently support importing onnx models. As of writing this answer it's an open feature request.
While not guaranteed to work, a potential solution is to use a tool developed by Microsoft called MMdnn (no it's not windows only!) which supports conversion to and from various frameworks. Unfortunately onnx can only be a target of a conversion, and not a source. That said you may be able to import your model to another framework, then use MMdnn to convert from that framework to pytorch. Obviously this isn't ideal and the potential for success will depend on how other frameworks use onnx which may not be amenable to the way MMdnn works.
Update August 2022
Unfortunately it appears the feature request was rejected and Mmdnn has been abandoned. There are some more recent 3rd party tools that provide some ability to import onnx into pytorch like onnx2pytorch and onnx-pytorch. Neither of these tools appear to be actively developed, though pytorch and onnx are relatively stable at this point so hopefully these tools remain relevant in the future (official support would be better IMO). Note that both of these tools have unaddressed issues, so it may be necessary to try both of them if one doesn't work for you.
Update September 2022
Based on the comment from #DanNissenbaum there is a newer 3rd party tool onnx2torch that is being actively developed and maintained.
I trained a model in AZURE ML. Now i want to use that model in my ios app to predict the outputĀ .
How to download the model from AZURE and use it my swift code.
As far as I know, the model could run in Azure Machine Learning Studio.It seems that you are unable to download it, the model could do nothing outside of Azure ML.
Here is a similar post for you to refer, I have also tried #Ahmet's
method, but result is like #mrjrdnthms says.