I have a model that I am trying to train on my local machine, but it needs more RAM than I have on my computer.
Because of this, I wish to train this model on Google Cloud ML.
This model that I am trying to train uses Reinforcement Learning and takes some actions and receives rewards from an environment developed in Python that takes as input a CSV file.
How can I export these to be trained on Google Cloud ML?
Can these rewards files be stored in Google cloud storage? Tensorflow reads such files natively is you use tf.file
Related
I use the TensorFlow models object detection to train a model on the cloud with this tutorial and I would like to know if there is an option to export the model also with the Cloud ML engine or with Google Cloud Function?
In their tutorial there is an only local example
I have train model and now I don't want to create an instance (or use my laptop) to create the exported .pb file for inference
Thanks for the help
Take a look at this Tutorials:
https://cloud.google.com/ai-platform/docs/getting-started-keras
https://cloud.google.com/ai-platform/docs/getting-started-tensorflow-estimator
I'm using ML Engine to run a hyperparameter tuning job for a Keras / Tensorflow model. I originally had set the machine type to be complex_model_l which is $1.65/hour. However, I'm using a TFRecords saved on Google Cloud Storage for my training and validation sets.
Given that they only take up ~6GB of space combined, is there any need for such a large machine? Could I use a standard machine (costs $0.27/hour) and run the tuning job as quickly?
Any advice would be awesome! I'm just not sure to what degree Tensorflow can make use of multiple cores by default.
Thanks!
If I am not using the notebook on AWS but instead just the Sagemaker CLI and want to train a model, can I specify a local path to read from and write to?
If you use local mode with the SageMaker Python SDK, you can train using local data:
from sagemaker.mxnet import MXNet
mxnet_estimator = MXNet('train.py',
train_instance_type='local',
train_instance_count=1)
mxnet_estimator.fit('file:///tmp/my_training_data')
However, this only works if you are training a model locally, not on SageMaker. If you want to train on SageMaker, then yes, you do need to use S3.
For more about local mode: https://github.com/aws/sagemaker-python-sdk#local-mode
As far as I know, you cannot do that. Sagemaker's framework and estimator API makes it easy for SageMaker to feed in data to the model at every iteration or epoch. Feeding from local would drastically slow down the process.
That begs the question - qhy not use S3. Its cheap and fast.
I have implemented a neural network model using Python and Tensorflow, which normally runs on my own computer.
Now I would like to train it on new datasets on the Google Cloud Platform. Do you think it is possible? Do I need to change my code?
Thank you very much for your help!
Google Cloud offers the Cloud ML Engine service, which allows to train your models and perform predictions without the need of running and maintaining an instance with the required software.
In order to run the TensorFlow NN models you already have, you will not need to change your code, you will only have to package the trainer appropriately, as described in the documentation, and run a ML Engine job that performs the training itself. Once you have your model, you can also deploy it in the same service and later get predictions with different features depending on your requirements (urgency in getting the predictions, data set sources, etc.).
Alternatively, as suggested in the comments, you can always launch a Compute Engine instance and run there your TensorFlow model as if you were doing it locally in your computer. However, I would strongly recommend the approach I proposed earlier, as you will be saving some money, because you will only be charged for your usage (training jobs and/or predictions) and do not need to configure an instance from scratch.
I am using Google Cloud Datalab notebook to train my tensorflow model. I want to save the trained model for offline prediction. However, I am clueless on how to save the model. Should I use any tensorflow model saving method or is there any datalab/google cloud storage specific method to do so? Any help in this regard is highly appreciated.
You can use any tensorflow model saving method, but I would suggest that you save it into a Google Cloud Storage bucket and not to local disk. Most tensorflow methods accept Google Cloud Storage paths in place of file names, using the gs:// prefix.
I would suggest using the SavedModelBuilder as it is currently the most portable. There is an example here: https://github.com/GoogleCloudPlatform/cloudml-samples/blob/master/flowers/trainer/model.py#L393