Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'module' object has no attribute 'feature_column'

I ran the official tutorial from Google (link here). It ran fine locally but I got stuck on the part where I need to train the network on the Google Cloud Platform. I ran the following code on my terminal:

JOB_NAME=census_single_1
OUTPUT_PATH=gs://$BUCKET_NAME/$JOB_NAME
gcloud ml-engine jobs submit training $JOB_NAME \
--job-dir $OUTPUT_PATH \
--runtime-version 1.0 \
--module-name trainer.task \
--package-path trainer/ \
--region $REGION \
-- \
--train-files $TRAIN_DATA \
--eval-files $EVAL_DATA \
--train-steps 1000 \
--verbosity DEBUG

And I got the following error message:

"Traceback (most recent call last):\n File \"/usr/lib/python2.7/runpy.py\", line 162, in _run_module_as_main\n
\"main\", fname, loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/root/.local/lib/python2.7/site-packages/trainer/task.py\", line 4, in \n import model\n File \"/root/.local/lib/python2.7/site-packages/trainer/model.py\", line 40, in \n
tf.feature_column.categorical_column_with_vocabulary_list(\nAttributeError: 'module' object has no attribute 'feature_column'\n"

// UPDATE

Never mind. I figured it out. It turns out the --runtime-version argument controls the Cloud ML Runtime Version (link). In the tutorial it was specified as 1.0, and that corresponds to Tensorflow v 1.0.1, which does not have tf.feature_column.* because it was just introduced in Tensorflow v 1.2.0 on June 16, 2017

// UPDATE 2

The Google tutorial has been updated to use --runtime-version 1.2 instead of --runtime-version 1.0 as of today, Jun 29, 2017. I don't know if they saw my post but this was changed between Jun 28 and Jun 29. Future users on that tutorial shouldn't experience the same issue I had.

like image 900
Yanfeng Liu Avatar asked Jun 28 '17 20:06

Yanfeng Liu


2 Answers

This could also happen from updating Google Cloud SDK, in which case pip install --upgrade tensorflow should do the job.

like image 135
Gal_M Avatar answered Nov 15 '22 10:11

Gal_M


I faced this problem with an outdated version of tensorflow. Updating it to the latest build helped.

like image 36
Chitransh Gaurav Avatar answered Nov 15 '22 08:11

Chitransh Gaurav