Search code examples
pythontensorflowgoogle-cloud-mlgoogle-cloud-ml-engine

How to use cloud ML for predictions on csv files rather than json?


Also can someone list out detailed steps to train and deploy a tensorflow model on Gcloud? I have my own code that I would not like to change. It seems like the code has to be in some sort of aa rigid format for it to be used on Gcloud, for example the task.py file, etc.


Solution

  • I just went through this process myself for the first time 2 weeks ago. What I'd recommend is using this tutorial (created by the kind folks at Google).

    I don't remember running into any big issues, but let me know if you hit any road blocks and I might be able to help you out.

    To change the prediction input from json to csv in the example from the above linked tutorial, you'll notice that the default given is 'JSON', but this can be changed to 'CSV' (source):

    parser.add_argument(
          '--export-format',
          help='The input format of the exported SavedModel binary',
          choices=['JSON', 'CSV', 'EXAMPLE'],
          default='JSON'
      )
    

    This means you can specify --export-format 'CSV' when you create the model. For example:

    python trainer/task.py \
    --train-files ~/Documents/data/adult.data.csv \
    --eval-files ~/Documents/data/adult.test.csv \
    --job-dir ~/Documents/models/census/v1 \
    --train-steps 100 \
    --verbosity 'DEBUG' \
    --export-format 'CSV'