Skip to content

Instantly share code, notes, and snippets.

@martinwicke
Last active January 9, 2022 08:14
Show Gist options
  • Save martinwicke/6838c23abdc53e6bcda36ed9f40cff39 to your computer and use it in GitHub Desktop.
Save martinwicke/6838c23abdc53e6bcda36ed9f40cff39 to your computer and use it in GitHub Desktop.
Estimator demo using Automobile dataset
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"from __future__ import division\n",
"from __future__ import absolute_import"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# First thing to do: Download https://archive.ics.uci.edu/ml/machine-learning-databases/autos/imports-85.data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# We're using pandas to read the CSV file. This is easy for small datasets, but for large and complex datasets,\n",
"# tensorflow parsing and processing functions are more powerful.\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# The CSV file does not have a header, so we have to fill in column names.\n",
"names = [\n",
" 'symboling', \n",
" 'normalized-losses', \n",
" 'make', \n",
" 'fuel-type', \n",
" 'aspiration',\n",
" 'num-of-doors',\n",
" 'body-style',\n",
" 'drive-wheels',\n",
" 'engine-location',\n",
" 'wheel-base',\n",
" 'length',\n",
" 'width',\n",
" 'height',\n",
" 'curb-weight',\n",
" 'engine-type',\n",
" 'num-of-cylinders',\n",
" 'engine-size',\n",
" 'fuel-system',\n",
" 'bore',\n",
" 'stroke',\n",
" 'compression-ratio',\n",
" 'horsepower',\n",
" 'peak-rpm',\n",
" 'city-mpg',\n",
" 'highway-mpg',\n",
" 'price',\n",
"]\n",
"\n",
"# We also have to specify dtypes.\n",
"dtypes = {\n",
" 'symboling': np.int32, \n",
" 'normalized-losses': np.float32, \n",
" 'make': str, \n",
" 'fuel-type': str, \n",
" 'aspiration': str,\n",
" 'num-of-doors': str,\n",
" 'body-style': str,\n",
" 'drive-wheels': str,\n",
" 'engine-location': str,\n",
" 'wheel-base': np.float32,\n",
" 'length': np.float32,\n",
" 'width': np.float32,\n",
" 'height': np.float32,\n",
" 'curb-weight': np.float32,\n",
" 'engine-type': str,\n",
" 'num-of-cylinders': str,\n",
" 'engine-size': np.float32,\n",
" 'fuel-system': str,\n",
" 'bore': np.float32,\n",
" 'stroke': np.float32,\n",
" 'compression-ratio': np.float32,\n",
" 'horsepower': np.float32,\n",
" 'peak-rpm': np.float32,\n",
" 'city-mpg': np.float32,\n",
" 'highway-mpg': np.float32,\n",
" 'price': np.float32, \n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Read the file.\n",
"df = pd.read_csv('imports-85.data', names=names, dtype=dtypes, na_values='?')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Some rows don't have price data, we can't use those.\n",
"df = df.dropna(axis='rows', how='any', subset=['price'])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Fill missing values in continuous columns with zeros instead of NaN.\n",
"float_columns = [k for k,v in dtypes.items() if v == np.float32]\n",
"df[float_columns] = df[float_columns].fillna(value=0., axis='columns')\n",
"# Fill missing values in continuous columns with '' instead of NaN (NaN mixed with strings is very bad for us).\n",
"string_columns = [k for k,v in dtypes.items() if v == str]\n",
"df[string_columns] = df[string_columns].fillna(value='', axis='columns')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Split the data into a training set and an eval set.\n",
"training_data = df[:160]\n",
"eval_data = df[160:]\n",
"\n",
"# Separate input features from labels\n",
"training_label = training_data.pop('price')\n",
"eval_label = eval_data.pop('price')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"please make sure that version >= 1.2:\n",
"1.2.0-rc0\n"
]
}
],
"source": [
"# Now we can start using some TensorFlow.\n",
"import tensorflow as tf\n",
"print('please make sure that version >= 1.2:')\n",
"print(tf.__version__)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Make input function for training: \n",
"# num_epochs=None -> will cycle through input data forever\n",
"# shuffle=True -> randomize order of input data\n",
"training_input_fn = tf.estimator.inputs.pandas_input_fn(x=training_data, y=training_label, batch_size=64, shuffle=True, num_epochs=None)\n",
"\n",
"# Make input function for evaluation:\n",
"# shuffle=False -> do not randomize input data\n",
"eval_input_fn = tf.estimator.inputs.pandas_input_fn(x=eval_data, y=eval_label, batch_size=64, shuffle=False)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Describe how the model should interpret the inputs. The names of the feature columns have to match the names\n",
"# of the series in the dataframe.\n",
"\n",
"symboling = tf.feature_column.numeric_column('symboling')\n",
"normalized_losses = tf.feature_column.numeric_column('normalized-losses')\n",
"make = tf.feature_column.categorical_column_with_hash_bucket('make', 50)\n",
"fuel_type = tf.feature_column.categorical_column_with_vocabulary_list('fuel-type', vocabulary_list=['diesel', 'gas'])\n",
"aspiration = tf.feature_column.categorical_column_with_vocabulary_list('aspiration', vocabulary_list=['std', 'turbo'])\n",
"num_of_doors = tf.feature_column.categorical_column_with_vocabulary_list('num-of-doors', vocabulary_list=['two', 'four'])\n",
"body_style = tf.feature_column.categorical_column_with_vocabulary_list('body-style', vocabulary_list=['hardtop', 'wagon', 'sedan', 'hatchback', 'convertible'])\n",
"drive_wheels = tf.feature_column.categorical_column_with_vocabulary_list('drive-wheels', vocabulary_list=['4wd', 'rwd', 'fwd'])\n",
"engine_location = tf.feature_column.categorical_column_with_vocabulary_list('engine-location', vocabulary_list=['front', 'rear'])\n",
"wheel_base = tf.feature_column.numeric_column('wheel-base')\n",
"length = tf.feature_column.numeric_column('length')\n",
"width = tf.feature_column.numeric_column('width')\n",
"height = tf.feature_column.numeric_column('height')\n",
"curb_weight = tf.feature_column.numeric_column('curb-weight')\n",
"engine_type = tf.feature_column.categorical_column_with_vocabulary_list('engine-type', ['dohc', 'dohcv', 'l', 'ohc', 'ohcf', 'ohcv', 'rotor'])\n",
"num_of_cylinders = tf.feature_column.categorical_column_with_vocabulary_list('num-of-cylinders', ['eight', 'five', 'four', 'six', 'three', 'twelve', 'two'])\n",
"engine_size = tf.feature_column.numeric_column('engine-size')\n",
"fuel_system = tf.feature_column.categorical_column_with_vocabulary_list('fuel-system', ['1bbl', '2bbl', '4bbl', 'idi', 'mfi', 'mpfi', 'spdi', 'spfi'])\n",
"bore = tf.feature_column.numeric_column('bore')\n",
"stroke = tf.feature_column.numeric_column('stroke')\n",
"compression_ratio = tf.feature_column.numeric_column('compression-ratio')\n",
"horsepower = tf.feature_column.numeric_column('horsepower')\n",
"peak_rpm = tf.feature_column.numeric_column('peak-rpm')\n",
"city_mpg = tf.feature_column.numeric_column('city-mpg')\n",
"highway_mpg = tf.feature_column.numeric_column('highway-mpg')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"linear_features = [symboling, normalized_losses, make, fuel_type, aspiration, num_of_doors,\n",
" body_style, drive_wheels, engine_location, wheel_base, length, width,\n",
" height, curb_weight, engine_type, num_of_cylinders, engine_size, fuel_system,\n",
" bore, stroke, compression_ratio, horsepower, peak_rpm, city_mpg, highway_mpg]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Using default config.\n",
"WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmp6ZlFc0\n",
"INFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5, '_task_type': None, '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2d61bac10>, '_model_dir': '/tmp/tmp6ZlFc0', '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_session_config': None, '_tf_random_seed': None, '_environment': 'local', '_num_worker_replicas': 0, '_task_id': 0, '_save_summary_steps': 100, '_tf_config': gpu_options {\n",
" per_process_gpu_memory_fraction: 1\n",
"}\n",
", '_evaluation_master': '', '_master': ''}\n"
]
}
],
"source": [
"regressor = tf.contrib.learn.LinearRegressor(feature_columns=linear_features)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Create CheckpointSaverHook.\n",
"INFO:tensorflow:Saving checkpoints for 1 into /tmp/tmpNU0eqz/model.ckpt.\n",
"INFO:tensorflow:loss = 2.413e+08, step = 1\n",
"INFO:tensorflow:global_step/sec: 176.967\n",
"INFO:tensorflow:loss = 8.0506e+07, step = 101 (0.570 sec)\n",
"INFO:tensorflow:global_step/sec: 199.97\n",
"INFO:tensorflow:loss = 6.6745e+07, step = 201 (0.496 sec)\n",
"INFO:tensorflow:global_step/sec: 216.747\n",
"INFO:tensorflow:loss = 6.00864e+07, step = 301 (0.465 sec)\n",
"INFO:tensorflow:global_step/sec: 191.496\n",
"INFO:tensorflow:loss = 3.47049e+07, step = 401 (0.522 sec)\n",
"INFO:tensorflow:global_step/sec: 208.642\n",
"INFO:tensorflow:loss = 3.39389e+07, step = 501 (0.478 sec)\n",
"INFO:tensorflow:global_step/sec: 202.928\n",
"INFO:tensorflow:loss = 4.3715e+07, step = 601 (0.494 sec)\n",
"INFO:tensorflow:global_step/sec: 195.74\n",
"INFO:tensorflow:loss = 4.14391e+07, step = 701 (0.510 sec)\n",
"INFO:tensorflow:global_step/sec: 207.903\n",
"INFO:tensorflow:loss = 3.20546e+07, step = 801 (0.481 sec)\n",
"INFO:tensorflow:global_step/sec: 198.331\n",
"INFO:tensorflow:loss = 3.13368e+07, step = 901 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 207.86\n",
"INFO:tensorflow:loss = 3.19198e+07, step = 1001 (0.482 sec)\n",
"INFO:tensorflow:global_step/sec: 200.102\n",
"INFO:tensorflow:loss = 3.91971e+07, step = 1101 (0.499 sec)\n",
"INFO:tensorflow:global_step/sec: 194.879\n",
"INFO:tensorflow:loss = 3.59553e+07, step = 1201 (0.513 sec)\n",
"INFO:tensorflow:global_step/sec: 195.484\n",
"INFO:tensorflow:loss = 3.05773e+07, step = 1301 (0.517 sec)\n",
"INFO:tensorflow:global_step/sec: 190.228\n",
"INFO:tensorflow:loss = 3.37149e+07, step = 1401 (0.517 sec)\n",
"INFO:tensorflow:global_step/sec: 200.541\n",
"INFO:tensorflow:loss = 1.99288e+07, step = 1501 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 198.025\n",
"INFO:tensorflow:loss = 2.11798e+07, step = 1601 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 197.413\n",
"INFO:tensorflow:loss = 2.43542e+07, step = 1701 (0.502 sec)\n",
"INFO:tensorflow:global_step/sec: 204.236\n",
"INFO:tensorflow:loss = 3.86619e+07, step = 1801 (0.493 sec)\n",
"INFO:tensorflow:global_step/sec: 198.07\n",
"INFO:tensorflow:loss = 1.96792e+07, step = 1901 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 217.409\n",
"INFO:tensorflow:loss = 2.44097e+07, step = 2001 (0.461 sec)\n",
"INFO:tensorflow:global_step/sec: 210.291\n",
"INFO:tensorflow:loss = 1.76028e+07, step = 2101 (0.476 sec)\n",
"INFO:tensorflow:global_step/sec: 199.749\n",
"INFO:tensorflow:loss = 3.83393e+07, step = 2201 (0.500 sec)\n",
"INFO:tensorflow:global_step/sec: 214.489\n",
"INFO:tensorflow:loss = 1.82325e+07, step = 2301 (0.466 sec)\n",
"INFO:tensorflow:global_step/sec: 202.679\n",
"INFO:tensorflow:loss = 3.6999e+07, step = 2401 (0.491 sec)\n",
"INFO:tensorflow:global_step/sec: 212.171\n",
"INFO:tensorflow:loss = 3.70806e+07, step = 2501 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 197.062\n",
"INFO:tensorflow:loss = 3.35983e+07, step = 2601 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 204.514\n",
"INFO:tensorflow:loss = 3.34915e+07, step = 2701 (0.489 sec)\n",
"INFO:tensorflow:global_step/sec: 204.905\n",
"INFO:tensorflow:loss = 1.7547e+07, step = 2801 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 204.146\n",
"INFO:tensorflow:loss = 2.43095e+07, step = 2901 (0.489 sec)\n",
"INFO:tensorflow:global_step/sec: 196.715\n",
"INFO:tensorflow:loss = 1.35012e+07, step = 3001 (0.508 sec)\n",
"INFO:tensorflow:global_step/sec: 198.609\n",
"INFO:tensorflow:loss = 3.57368e+07, step = 3101 (0.500 sec)\n",
"INFO:tensorflow:global_step/sec: 199.429\n",
"INFO:tensorflow:loss = 1.60761e+07, step = 3201 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 198.273\n",
"INFO:tensorflow:loss = 2.35629e+07, step = 3301 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 195.878\n",
"INFO:tensorflow:loss = 2.66036e+07, step = 3401 (0.511 sec)\n",
"INFO:tensorflow:global_step/sec: 212.195\n",
"INFO:tensorflow:loss = 2.08395e+07, step = 3501 (0.471 sec)\n",
"INFO:tensorflow:global_step/sec: 193.941\n",
"INFO:tensorflow:loss = 2.37839e+07, step = 3601 (0.517 sec)\n",
"INFO:tensorflow:global_step/sec: 204.155\n",
"INFO:tensorflow:loss = 2.1417e+07, step = 3701 (0.490 sec)\n",
"INFO:tensorflow:global_step/sec: 199.325\n",
"INFO:tensorflow:loss = 2.40825e+07, step = 3801 (0.501 sec)\n",
"INFO:tensorflow:global_step/sec: 201.735\n",
"INFO:tensorflow:loss = 2.53497e+07, step = 3901 (0.495 sec)\n",
"INFO:tensorflow:global_step/sec: 195.295\n",
"INFO:tensorflow:loss = 2.46902e+07, step = 4001 (0.512 sec)\n",
"INFO:tensorflow:global_step/sec: 204.348\n",
"INFO:tensorflow:loss = 1.41864e+07, step = 4101 (0.491 sec)\n",
"INFO:tensorflow:global_step/sec: 192.389\n",
"INFO:tensorflow:loss = 1.93114e+07, step = 4201 (0.520 sec)\n",
"INFO:tensorflow:global_step/sec: 201.688\n",
"INFO:tensorflow:loss = 2.07875e+07, step = 4301 (0.494 sec)\n",
"INFO:tensorflow:global_step/sec: 203.185\n",
"INFO:tensorflow:loss = 1.92451e+07, step = 4401 (0.492 sec)\n",
"INFO:tensorflow:global_step/sec: 196.942\n",
"INFO:tensorflow:loss = 2.25099e+07, step = 4501 (0.509 sec)\n",
"INFO:tensorflow:global_step/sec: 200.913\n",
"INFO:tensorflow:loss = 3.70702e+07, step = 4601 (0.497 sec)\n",
"INFO:tensorflow:global_step/sec: 201.091\n",
"INFO:tensorflow:loss = 2.03945e+07, step = 4701 (0.497 sec)\n",
"INFO:tensorflow:global_step/sec: 222.047\n",
"INFO:tensorflow:loss = 1.86867e+07, step = 4801 (0.449 sec)\n",
"INFO:tensorflow:global_step/sec: 208.696\n",
"INFO:tensorflow:loss = 3.36875e+07, step = 4901 (0.480 sec)\n",
"INFO:tensorflow:global_step/sec: 207.015\n",
"INFO:tensorflow:loss = 2.07768e+07, step = 5001 (0.481 sec)\n",
"INFO:tensorflow:global_step/sec: 196.225\n",
"INFO:tensorflow:loss = 2.37784e+07, step = 5101 (0.509 sec)\n",
"INFO:tensorflow:global_step/sec: 218.157\n",
"INFO:tensorflow:loss = 2.1156e+07, step = 5201 (0.462 sec)\n",
"INFO:tensorflow:global_step/sec: 211.054\n",
"INFO:tensorflow:loss = 2.725e+07, step = 5301 (0.478 sec)\n",
"INFO:tensorflow:global_step/sec: 209.87\n",
"INFO:tensorflow:loss = 2.8351e+07, step = 5401 (0.473 sec)\n",
"INFO:tensorflow:global_step/sec: 221.093\n",
"INFO:tensorflow:loss = 1.76603e+07, step = 5501 (0.447 sec)\n",
"INFO:tensorflow:global_step/sec: 214.878\n",
"INFO:tensorflow:loss = 2.43624e+07, step = 5601 (0.470 sec)\n",
"INFO:tensorflow:global_step/sec: 210.194\n",
"INFO:tensorflow:loss = 1.40775e+07, step = 5701 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 229.605\n",
"INFO:tensorflow:loss = 1.59308e+07, step = 5801 (0.433 sec)\n",
"INFO:tensorflow:global_step/sec: 234.067\n",
"INFO:tensorflow:loss = 2.976e+07, step = 5901 (0.432 sec)\n",
"INFO:tensorflow:global_step/sec: 214.035\n",
"INFO:tensorflow:loss = 2.19687e+07, step = 6001 (0.464 sec)\n",
"INFO:tensorflow:global_step/sec: 223.271\n",
"INFO:tensorflow:loss = 2.21959e+07, step = 6101 (0.453 sec)\n",
"INFO:tensorflow:global_step/sec: 207.604\n",
"INFO:tensorflow:loss = 1.83792e+07, step = 6201 (0.478 sec)\n",
"INFO:tensorflow:global_step/sec: 208.606\n",
"INFO:tensorflow:loss = 1.93478e+07, step = 6301 (0.480 sec)\n",
"INFO:tensorflow:global_step/sec: 197.773\n",
"INFO:tensorflow:loss = 2.01267e+07, step = 6401 (0.506 sec)\n",
"INFO:tensorflow:global_step/sec: 209.845\n",
"INFO:tensorflow:loss = 1.29307e+07, step = 6501 (0.479 sec)\n",
"INFO:tensorflow:global_step/sec: 194.682\n",
"INFO:tensorflow:loss = 2.8945e+07, step = 6601 (0.511 sec)\n",
"INFO:tensorflow:global_step/sec: 204.713\n",
"INFO:tensorflow:loss = 2.75792e+07, step = 6701 (0.487 sec)\n",
"INFO:tensorflow:global_step/sec: 196.828\n",
"INFO:tensorflow:loss = 1.97477e+07, step = 6801 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 205.33\n",
"INFO:tensorflow:loss = 1.99781e+07, step = 6901 (0.491 sec)\n",
"INFO:tensorflow:global_step/sec: 186.738\n",
"INFO:tensorflow:loss = 2.87054e+07, step = 7001 (0.534 sec)\n",
"INFO:tensorflow:global_step/sec: 218.389\n",
"INFO:tensorflow:loss = 1.15199e+07, step = 7101 (0.456 sec)\n",
"INFO:tensorflow:global_step/sec: 206.017\n",
"INFO:tensorflow:loss = 2.23859e+07, step = 7201 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 210.881\n",
"INFO:tensorflow:loss = 2.92122e+07, step = 7301 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 203.424\n",
"INFO:tensorflow:loss = 2.21403e+07, step = 7401 (0.491 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 191.929\n",
"INFO:tensorflow:loss = 2.00178e+07, step = 7501 (0.518 sec)\n",
"INFO:tensorflow:global_step/sec: 203.697\n",
"INFO:tensorflow:loss = 1.53318e+07, step = 7601 (0.495 sec)\n",
"INFO:tensorflow:global_step/sec: 202.307\n",
"INFO:tensorflow:loss = 2.0854e+07, step = 7701 (0.495 sec)\n",
"INFO:tensorflow:global_step/sec: 203.504\n",
"INFO:tensorflow:loss = 1.40464e+07, step = 7801 (0.490 sec)\n",
"INFO:tensorflow:global_step/sec: 194.591\n",
"INFO:tensorflow:loss = 1.54422e+07, step = 7901 (0.513 sec)\n",
"INFO:tensorflow:global_step/sec: 199.267\n",
"INFO:tensorflow:loss = 2.12707e+07, step = 8001 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 195.141\n",
"INFO:tensorflow:loss = 2.22916e+07, step = 8101 (0.509 sec)\n",
"INFO:tensorflow:global_step/sec: 194.245\n",
"INFO:tensorflow:loss = 1.87815e+07, step = 8201 (0.518 sec)\n",
"INFO:tensorflow:global_step/sec: 205.331\n",
"INFO:tensorflow:loss = 1.70511e+07, step = 8301 (0.484 sec)\n",
"INFO:tensorflow:global_step/sec: 193.251\n",
"INFO:tensorflow:loss = 1.845e+07, step = 8401 (0.518 sec)\n",
"INFO:tensorflow:global_step/sec: 194.904\n",
"INFO:tensorflow:loss = 1.34779e+07, step = 8501 (0.515 sec)\n",
"INFO:tensorflow:global_step/sec: 202.893\n",
"INFO:tensorflow:loss = 2.24741e+07, step = 8601 (0.490 sec)\n",
"INFO:tensorflow:global_step/sec: 198.084\n",
"INFO:tensorflow:loss = 1.51334e+07, step = 8701 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 195.539\n",
"INFO:tensorflow:loss = 1.41038e+07, step = 8801 (0.515 sec)\n",
"INFO:tensorflow:global_step/sec: 196.798\n",
"INFO:tensorflow:loss = 1.2088e+07, step = 8901 (0.508 sec)\n",
"INFO:tensorflow:global_step/sec: 201.058\n",
"INFO:tensorflow:loss = 2.5259e+07, step = 9001 (0.499 sec)\n",
"INFO:tensorflow:global_step/sec: 206.198\n",
"INFO:tensorflow:loss = 1.56701e+07, step = 9101 (0.484 sec)\n",
"INFO:tensorflow:global_step/sec: 205.651\n",
"INFO:tensorflow:loss = 1.74854e+07, step = 9201 (0.483 sec)\n",
"INFO:tensorflow:global_step/sec: 214.525\n",
"INFO:tensorflow:loss = 1.77746e+07, step = 9301 (0.466 sec)\n",
"INFO:tensorflow:global_step/sec: 199.056\n",
"INFO:tensorflow:loss = 2.04472e+07, step = 9401 (0.503 sec)\n",
"INFO:tensorflow:global_step/sec: 191.095\n",
"INFO:tensorflow:loss = 3.08347e+07, step = 9501 (0.526 sec)\n",
"INFO:tensorflow:global_step/sec: 197.268\n",
"INFO:tensorflow:loss = 1.21763e+07, step = 9601 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 209.745\n",
"INFO:tensorflow:loss = 2.25766e+07, step = 9701 (0.476 sec)\n",
"INFO:tensorflow:global_step/sec: 211.345\n",
"INFO:tensorflow:loss = 1.2244e+07, step = 9801 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 200.21\n",
"INFO:tensorflow:loss = 1.46577e+07, step = 9901 (0.500 sec)\n",
"INFO:tensorflow:Saving checkpoints for 10000 into /tmp/tmpNU0eqz/model.ckpt.\n",
"INFO:tensorflow:Loss for final step: 1.43916e+07.\n"
]
},
{
"data": {
"text/plain": [
"LinearRegressor(params={'gradient_clip_norm': None, 'head': <tensorflow.contrib.learn.python.learn.estimators.head._RegressionHead object at 0x7f34ca5ac190>, 'joint_weights': False, 'optimizer': None, 'feature_columns': [_NumericColumn(key='symboling', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='normalized-losses', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _HashedCategoricalColumn(key='make', hash_bucket_size=50, dtype=tf.string), _VocabularyListCategoricalColumn(key='fuel-type', vocabulary_list=('diesel', 'gas'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='aspiration', vocabulary_list=('std', 'turbo'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='num-of-doors', vocabulary_list=('two', 'four'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='body-style', vocabulary_list=('hardtop', 'wagon', 'sedan', 'hatchback', 'convertible'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='drive-wheels', vocabulary_list=('4wd', 'rwd', 'fwd'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='engine-location', vocabulary_list=('front', 'rear'), dtype=tf.string, default_value=-1), _NumericColumn(key='wheel-base', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='length', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='width', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='height', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='curb-weight', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _VocabularyListCategoricalColumn(key='engine-type', vocabulary_list=('dohc', 'dohcv', 'l', 'ohc', 'ohcf', 'ohcv', 'rotor'), dtype=tf.string, default_value=-1), _VocabularyListCategoricalColumn(key='num-of-cylinders', vocabulary_list=('eight', 'five', 'four', 'six', 'three', 'twelve', 'two'), dtype=tf.string, default_value=-1), _NumericColumn(key='engine-size', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _VocabularyListCategoricalColumn(key='fuel-system', vocabulary_list=('1bbl', '2bbl', '4bbl', 'idi', 'mfi', 'mpfi', 'spdi', 'spfi'), dtype=tf.string, default_value=-1), _NumericColumn(key='bore', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='stroke', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='compression-ratio', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='horsepower', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='peak-rpm', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='city-mpg', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='highway-mpg', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None)]})"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"regressor.fit(input_fn=training_input_fn, steps=10000)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Starting evaluation at 2017-05-17-21:48:53\n",
"INFO:tensorflow:Restoring parameters from /tmp/tmpNU0eqz/model.ckpt-10000\n",
"INFO:tensorflow:Finished evaluation at 2017-05-17-21:48:54\n",
"INFO:tensorflow:Saving dict for global step 10000: global_step = 10000, loss = 7.96542e+06\n"
]
},
{
"data": {
"text/plain": [
"{'global_step': 10000, 'loss': 7965423.5}"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"regressor.evaluate(input_fn=eval_input_fn)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"dnn_features = [\n",
" #numerical features\n",
" symboling, normalized_losses, wheel_base, length, width, height, curb_weight, engine_size,\n",
" bore, stroke, compression_ratio, horsepower, peak_rpm, city_mpg, highway_mpg, \n",
" # densify categorical features:\n",
" tf.feature_column.indicator_column(make),\n",
" tf.feature_column.indicator_column(fuel_type),\n",
" tf.feature_column.indicator_column(aspiration),\n",
" tf.feature_column.indicator_column(num_of_doors),\n",
" tf.feature_column.indicator_column(body_style),\n",
" tf.feature_column.indicator_column(drive_wheels), \n",
" tf.feature_column.indicator_column(engine_location),\n",
" tf.feature_column.indicator_column(engine_type),\n",
" tf.feature_column.indicator_column(num_of_cylinders),\n",
" tf.feature_column.indicator_column(fuel_system),\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Using default config.\n",
"WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpnqPn3Q\n",
"INFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5, '_task_type': None, '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2d60a9bd0>, '_model_dir': '/tmp/tmpnqPn3Q', '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_session_config': None, '_tf_random_seed': None, '_environment': 'local', '_num_worker_replicas': 0, '_task_id': 0, '_save_summary_steps': 100, '_tf_config': gpu_options {\n",
" per_process_gpu_memory_fraction: 1\n",
"}\n",
", '_evaluation_master': '', '_master': ''}\n"
]
}
],
"source": [
"dnnregressor = tf.contrib.learn.DNNRegressor(feature_columns=dnn_features, hidden_units=[50, 30, 10])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Create CheckpointSaverHook.\n",
"INFO:tensorflow:Saving checkpoints for 1 into /tmp/tmpnqPn3Q/model.ckpt.\n",
"INFO:tensorflow:loss = 3.22914e+08, step = 1\n",
"INFO:tensorflow:global_step/sec: 219.187\n",
"INFO:tensorflow:loss = 3.491e+07, step = 101 (0.464 sec)\n",
"INFO:tensorflow:global_step/sec: 205.938\n",
"INFO:tensorflow:loss = 1.59505e+07, step = 201 (0.482 sec)\n",
"INFO:tensorflow:global_step/sec: 205.809\n",
"INFO:tensorflow:loss = 1.67622e+07, step = 301 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 197.773\n",
"INFO:tensorflow:loss = 1.92105e+07, step = 401 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 195.636\n",
"INFO:tensorflow:loss = 1.33924e+07, step = 501 (0.514 sec)\n",
"INFO:tensorflow:global_step/sec: 196.098\n",
"INFO:tensorflow:loss = 2.0106e+07, step = 601 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 200.687\n",
"INFO:tensorflow:loss = 1.12352e+07, step = 701 (0.498 sec)\n",
"INFO:tensorflow:global_step/sec: 204.846\n",
"INFO:tensorflow:loss = 1.22986e+07, step = 801 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 213.601\n",
"INFO:tensorflow:loss = 1.2512e+07, step = 901 (0.472 sec)\n",
"INFO:tensorflow:global_step/sec: 211.612\n",
"INFO:tensorflow:loss = 1.48472e+07, step = 1001 (0.464 sec)\n",
"INFO:tensorflow:global_step/sec: 220.501\n",
"INFO:tensorflow:loss = 8.40844e+06, step = 1101 (0.461 sec)\n",
"INFO:tensorflow:global_step/sec: 211.484\n",
"INFO:tensorflow:loss = 8.44797e+06, step = 1201 (0.472 sec)\n",
"INFO:tensorflow:global_step/sec: 212.557\n",
"INFO:tensorflow:loss = 7.00385e+06, step = 1301 (0.467 sec)\n",
"INFO:tensorflow:global_step/sec: 230.789\n",
"INFO:tensorflow:loss = 9.14419e+06, step = 1401 (0.429 sec)\n",
"INFO:tensorflow:global_step/sec: 205.606\n",
"INFO:tensorflow:loss = 9.5279e+06, step = 1501 (0.489 sec)\n",
"INFO:tensorflow:global_step/sec: 206.976\n",
"INFO:tensorflow:loss = 6.6255e+06, step = 1601 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 197.825\n",
"INFO:tensorflow:loss = 6.00631e+06, step = 1701 (0.502 sec)\n",
"INFO:tensorflow:global_step/sec: 195.028\n",
"INFO:tensorflow:loss = 7.70543e+06, step = 1801 (0.509 sec)\n",
"INFO:tensorflow:global_step/sec: 219.272\n",
"INFO:tensorflow:loss = 9.4826e+06, step = 1901 (0.464 sec)\n",
"INFO:tensorflow:global_step/sec: 190.787\n",
"INFO:tensorflow:loss = 9.36445e+06, step = 2001 (0.523 sec)\n",
"INFO:tensorflow:global_step/sec: 193.815\n",
"INFO:tensorflow:loss = 1.04711e+07, step = 2101 (0.516 sec)\n",
"INFO:tensorflow:global_step/sec: 209.743\n",
"INFO:tensorflow:loss = 7.58201e+06, step = 2201 (0.477 sec)\n",
"INFO:tensorflow:global_step/sec: 204.692\n",
"INFO:tensorflow:loss = 8.64958e+06, step = 2301 (0.491 sec)\n",
"INFO:tensorflow:global_step/sec: 203.376\n",
"INFO:tensorflow:loss = 6.88543e+06, step = 2401 (0.492 sec)\n",
"INFO:tensorflow:global_step/sec: 202.242\n",
"INFO:tensorflow:loss = 4.69487e+06, step = 2501 (0.494 sec)\n",
"INFO:tensorflow:global_step/sec: 240.692\n",
"INFO:tensorflow:loss = 5.28382e+06, step = 2601 (0.416 sec)\n",
"INFO:tensorflow:global_step/sec: 209.215\n",
"INFO:tensorflow:loss = 4.16122e+06, step = 2701 (0.480 sec)\n",
"INFO:tensorflow:global_step/sec: 198.782\n",
"INFO:tensorflow:loss = 7.92784e+06, step = 2801 (0.497 sec)\n",
"INFO:tensorflow:global_step/sec: 192.573\n",
"INFO:tensorflow:loss = 7.9074e+06, step = 2901 (0.522 sec)\n",
"INFO:tensorflow:global_step/sec: 212.379\n",
"INFO:tensorflow:loss = 6.87462e+06, step = 3001 (0.470 sec)\n",
"INFO:tensorflow:global_step/sec: 205.104\n",
"INFO:tensorflow:loss = 6.78068e+06, step = 3101 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 215.02\n",
"INFO:tensorflow:loss = 6.94585e+06, step = 3201 (0.463 sec)\n",
"INFO:tensorflow:global_step/sec: 197.712\n",
"INFO:tensorflow:loss = 1.02954e+07, step = 3301 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 197.414\n",
"INFO:tensorflow:loss = 5.35531e+06, step = 3401 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 204.421\n",
"INFO:tensorflow:loss = 4.74769e+06, step = 3501 (0.490 sec)\n",
"INFO:tensorflow:global_step/sec: 202.362\n",
"INFO:tensorflow:loss = 3.56324e+06, step = 3601 (0.495 sec)\n",
"INFO:tensorflow:global_step/sec: 208.304\n",
"INFO:tensorflow:loss = 7.61136e+06, step = 3701 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 222.428\n",
"INFO:tensorflow:loss = 6.08336e+06, step = 3801 (0.447 sec)\n",
"INFO:tensorflow:global_step/sec: 209.433\n",
"INFO:tensorflow:loss = 3.95651e+06, step = 3901 (0.485 sec)\n",
"INFO:tensorflow:global_step/sec: 187.938\n",
"INFO:tensorflow:loss = 5.55149e+06, step = 4001 (0.533 sec)\n",
"INFO:tensorflow:global_step/sec: 205.872\n",
"INFO:tensorflow:loss = 6.80143e+06, step = 4101 (0.486 sec)\n",
"INFO:tensorflow:global_step/sec: 183.963\n",
"INFO:tensorflow:loss = 7.18965e+06, step = 4201 (0.542 sec)\n",
"INFO:tensorflow:global_step/sec: 193.573\n",
"INFO:tensorflow:loss = 4.6761e+06, step = 4301 (0.517 sec)\n",
"INFO:tensorflow:global_step/sec: 200.71\n",
"INFO:tensorflow:loss = 2.98158e+06, step = 4401 (0.500 sec)\n",
"INFO:tensorflow:global_step/sec: 207.15\n",
"INFO:tensorflow:loss = 6.64037e+06, step = 4501 (0.484 sec)\n",
"INFO:tensorflow:global_step/sec: 199.069\n",
"INFO:tensorflow:loss = 4.07609e+06, step = 4601 (0.499 sec)\n",
"INFO:tensorflow:global_step/sec: 197.118\n",
"INFO:tensorflow:loss = 2.61921e+06, step = 4701 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 192.8\n",
"INFO:tensorflow:loss = 5.55107e+06, step = 4801 (0.516 sec)\n",
"INFO:tensorflow:global_step/sec: 189.872\n",
"INFO:tensorflow:loss = 3.51778e+06, step = 4901 (0.535 sec)\n",
"INFO:tensorflow:global_step/sec: 211.093\n",
"INFO:tensorflow:loss = 4.04648e+06, step = 5001 (0.472 sec)\n",
"INFO:tensorflow:global_step/sec: 184.25\n",
"INFO:tensorflow:loss = 3.56233e+06, step = 5101 (0.541 sec)\n",
"INFO:tensorflow:global_step/sec: 210.133\n",
"INFO:tensorflow:loss = 3.7764e+06, step = 5201 (0.482 sec)\n",
"INFO:tensorflow:global_step/sec: 198.005\n",
"INFO:tensorflow:loss = 2.44377e+06, step = 5301 (0.495 sec)\n",
"INFO:tensorflow:global_step/sec: 198.66\n",
"INFO:tensorflow:loss = 6.5769e+06, step = 5401 (0.511 sec)\n",
"INFO:tensorflow:global_step/sec: 190.708\n",
"INFO:tensorflow:loss = 3.70076e+06, step = 5501 (0.524 sec)\n",
"INFO:tensorflow:global_step/sec: 204.201\n",
"INFO:tensorflow:loss = 6.93209e+06, step = 5601 (0.483 sec)\n",
"INFO:tensorflow:global_step/sec: 202.983\n",
"INFO:tensorflow:loss = 3.69568e+06, step = 5701 (0.496 sec)\n",
"INFO:tensorflow:global_step/sec: 206.596\n",
"INFO:tensorflow:loss = 2.59145e+06, step = 5801 (0.487 sec)\n",
"INFO:tensorflow:global_step/sec: 211.526\n",
"INFO:tensorflow:loss = 4.70694e+06, step = 5901 (0.470 sec)\n",
"INFO:tensorflow:global_step/sec: 213.76\n",
"INFO:tensorflow:loss = 2.60545e+06, step = 6001 (0.466 sec)\n",
"INFO:tensorflow:global_step/sec: 220.998\n",
"INFO:tensorflow:loss = 5.55105e+06, step = 6101 (0.453 sec)\n",
"INFO:tensorflow:global_step/sec: 200.507\n",
"INFO:tensorflow:loss = 3.21904e+06, step = 6201 (0.496 sec)\n",
"INFO:tensorflow:global_step/sec: 222.679\n",
"INFO:tensorflow:loss = 4.14268e+06, step = 6301 (0.451 sec)\n",
"INFO:tensorflow:global_step/sec: 229.058\n",
"INFO:tensorflow:loss = 4.81932e+06, step = 6401 (0.436 sec)\n",
"INFO:tensorflow:global_step/sec: 208.461\n",
"INFO:tensorflow:loss = 3.18166e+06, step = 6501 (0.483 sec)\n",
"INFO:tensorflow:global_step/sec: 218.974\n",
"INFO:tensorflow:loss = 3.5313e+06, step = 6601 (0.456 sec)\n",
"INFO:tensorflow:global_step/sec: 207.385\n",
"INFO:tensorflow:loss = 2.94534e+06, step = 6701 (0.482 sec)\n",
"INFO:tensorflow:global_step/sec: 213.043\n",
"INFO:tensorflow:loss = 2.06027e+06, step = 6801 (0.471 sec)\n",
"INFO:tensorflow:global_step/sec: 198.342\n",
"INFO:tensorflow:loss = 3.38289e+06, step = 6901 (0.498 sec)\n",
"INFO:tensorflow:global_step/sec: 198.456\n",
"INFO:tensorflow:loss = 4.20299e+06, step = 7001 (0.505 sec)\n",
"INFO:tensorflow:global_step/sec: 200.212\n",
"INFO:tensorflow:loss = 3.04473e+06, step = 7101 (0.507 sec)\n",
"INFO:tensorflow:global_step/sec: 198.17\n",
"INFO:tensorflow:loss = 3.72165e+06, step = 7201 (0.496 sec)\n",
"INFO:tensorflow:global_step/sec: 212.793\n",
"INFO:tensorflow:loss = 4.78442e+06, step = 7301 (0.470 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 198.116\n",
"INFO:tensorflow:loss = 4.21432e+06, step = 7401 (0.510 sec)\n",
"INFO:tensorflow:global_step/sec: 202.815\n",
"INFO:tensorflow:loss = 3.10884e+06, step = 7501 (0.493 sec)\n",
"INFO:tensorflow:global_step/sec: 199.3\n",
"INFO:tensorflow:loss = 2.30774e+06, step = 7601 (0.498 sec)\n",
"INFO:tensorflow:global_step/sec: 227.64\n",
"INFO:tensorflow:loss = 3.16538e+06, step = 7701 (0.445 sec)\n",
"INFO:tensorflow:global_step/sec: 216.803\n",
"INFO:tensorflow:loss = 2.16325e+06, step = 7801 (0.456 sec)\n",
"INFO:tensorflow:global_step/sec: 222.97\n",
"INFO:tensorflow:loss = 4.19254e+06, step = 7901 (0.446 sec)\n",
"INFO:tensorflow:global_step/sec: 222.506\n",
"INFO:tensorflow:loss = 3.27005e+06, step = 8001 (0.454 sec)\n",
"INFO:tensorflow:global_step/sec: 220.794\n",
"INFO:tensorflow:loss = 3.39485e+06, step = 8101 (0.451 sec)\n",
"INFO:tensorflow:global_step/sec: 204.882\n",
"INFO:tensorflow:loss = 2.88965e+06, step = 8201 (0.493 sec)\n",
"INFO:tensorflow:global_step/sec: 210.89\n",
"INFO:tensorflow:loss = 4.03541e+06, step = 8301 (0.473 sec)\n",
"INFO:tensorflow:global_step/sec: 198.464\n",
"INFO:tensorflow:loss = 1.8358e+06, step = 8401 (0.508 sec)\n",
"INFO:tensorflow:global_step/sec: 198.038\n",
"INFO:tensorflow:loss = 2.85165e+06, step = 8501 (0.500 sec)\n",
"INFO:tensorflow:global_step/sec: 198.361\n",
"INFO:tensorflow:loss = 1.68505e+06, step = 8601 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 213.096\n",
"INFO:tensorflow:loss = 3.16152e+06, step = 8701 (0.471 sec)\n",
"INFO:tensorflow:global_step/sec: 209.367\n",
"INFO:tensorflow:loss = 2.23255e+06, step = 8801 (0.475 sec)\n",
"INFO:tensorflow:global_step/sec: 199.187\n",
"INFO:tensorflow:loss = 2.44422e+06, step = 8901 (0.503 sec)\n",
"INFO:tensorflow:global_step/sec: 198.963\n",
"INFO:tensorflow:loss = 2.98126e+06, step = 9001 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 192.586\n",
"INFO:tensorflow:loss = 3.03181e+06, step = 9101 (0.524 sec)\n",
"INFO:tensorflow:global_step/sec: 201.384\n",
"INFO:tensorflow:loss = 2.13724e+06, step = 9201 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 199.785\n",
"INFO:tensorflow:loss = 2.05773e+06, step = 9301 (0.503 sec)\n",
"INFO:tensorflow:global_step/sec: 212.812\n",
"INFO:tensorflow:loss = 2.25637e+06, step = 9401 (0.472 sec)\n",
"INFO:tensorflow:global_step/sec: 197.215\n",
"INFO:tensorflow:loss = 2.08347e+06, step = 9501 (0.504 sec)\n",
"INFO:tensorflow:global_step/sec: 205.228\n",
"INFO:tensorflow:loss = 1.82127e+06, step = 9601 (0.488 sec)\n",
"INFO:tensorflow:global_step/sec: 205.092\n",
"INFO:tensorflow:loss = 3.25608e+06, step = 9701 (0.490 sec)\n",
"INFO:tensorflow:global_step/sec: 209.62\n",
"INFO:tensorflow:loss = 2.75633e+06, step = 9801 (0.472 sec)\n",
"INFO:tensorflow:global_step/sec: 203.143\n",
"INFO:tensorflow:loss = 2.25092e+06, step = 9901 (0.497 sec)\n",
"INFO:tensorflow:Saving checkpoints for 10000 into /tmp/tmpnqPn3Q/model.ckpt.\n",
"INFO:tensorflow:Loss for final step: 1.62302e+06.\n"
]
},
{
"data": {
"text/plain": [
"DNNRegressor(params={'head': <tensorflow.contrib.learn.python.learn.estimators.head._RegressionHead object at 0x7fc2d60a98d0>, 'hidden_units': [50, 30, 10], 'feature_columns': (_NumericColumn(key='symboling', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='normalized-losses', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='wheel-base', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='length', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='width', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='height', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='curb-weight', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='engine-size', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='bore', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='stroke', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='compression-ratio', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='horsepower', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='peak-rpm', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='city-mpg', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _NumericColumn(key='highway-mpg', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None), _IndicatorColumn(categorical_column=_HashedCategoricalColumn(key='make', hash_bucket_size=50, dtype=tf.string)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='fuel-type', vocabulary_list=('diesel', 'gas'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='aspiration', vocabulary_list=('std', 'turbo'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='num-of-doors', vocabulary_list=('two', 'four'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='body-style', vocabulary_list=('hardtop', 'wagon', 'sedan', 'hatchback', 'convertible'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='drive-wheels', vocabulary_list=('4wd', 'rwd', 'fwd'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='engine-location', vocabulary_list=('front', 'rear'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='engine-type', vocabulary_list=('dohc', 'dohcv', 'l', 'ohc', 'ohcf', 'ohcv', 'rotor'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='num-of-cylinders', vocabulary_list=('eight', 'five', 'four', 'six', 'three', 'twelve', 'two'), dtype=tf.string, default_value=-1)), _IndicatorColumn(categorical_column=_VocabularyListCategoricalColumn(key='fuel-system', vocabulary_list=('1bbl', '2bbl', '4bbl', 'idi', 'mfi', 'mpfi', 'spdi', 'spfi'), dtype=tf.string, default_value=-1))), 'embedding_lr_multipliers': None, 'optimizer': None, 'dropout': None, 'gradient_clip_norm': None, 'activation_fn': <function relu at 0x7fc2d9ed87d0>, 'input_layer_min_slice_size': None})"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dnnregressor.fit(input_fn=training_input_fn, steps=10000)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Starting evaluation at 2017-05-18-02:27:00\n",
"INFO:tensorflow:Restoring parameters from /tmp/tmpnqPn3Q/model.ckpt-10000\n",
"INFO:tensorflow:Finished evaluation at 2017-05-18-02:27:00\n",
"INFO:tensorflow:Saving dict for global step 10000: global_step = 10000, loss = 9.60459e+06\n"
]
},
{
"data": {
"text/plain": [
"{'global_step': 10000, 'loss': 9604591.0}"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dnnregressor.evaluate(input_fn=eval_input_fn)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def experiment_fn(run_config, params):\n",
" # This function makes an Experiment, containing an Estimator and inputs for training and evaluation.\n",
" # You can use params and config here to customize the Estimator depending on the cluster or to use\n",
" # hyperparameter tuning.\n",
"\n",
" # Collect information for training\n",
" return tf.contrib.learn.Experiment(estimator=tf.contrib.learn.LinearRegressor(\n",
" feature_columns=linear_features, config=run_config),\n",
" train_input_fn=training_input_fn,\n",
" train_steps=10000,\n",
" eval_input_fn=eval_input_fn)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:uid (from tensorflow.contrib.learn.python.learn.estimators.run_config) is experimental and may change or be removed at any time, and without warning.\n",
"INFO:tensorflow:Using config: {'_model_dir': '/tmp/output_dir', '_save_checkpoints_secs': 600, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5, '_tf_random_seed': None, '_task_type': None, '_environment': 'local', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2d5195410>, '_tf_config': gpu_options {\n",
" per_process_gpu_memory_fraction: 1\n",
"}\n",
", '_num_worker_replicas': 0, '_task_id': 0, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_evaluation_master': '', '_keep_checkpoint_every_n_hours': 10000, '_master': '', '_session_config': None}\n",
"WARNING:tensorflow:uid (from tensorflow.contrib.learn.python.learn.estimators.run_config) is experimental and may change or be removed at any time, and without warning.\n",
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/monitors.py:268: __init__ (from tensorflow.contrib.learn.python.learn.monitors) is deprecated and will be removed after 2016-12-05.\n",
"Instructions for updating:\n",
"Monitors are deprecated. Please use tf.train.SessionRunHook.\n",
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Create CheckpointSaverHook.\n",
"INFO:tensorflow:Saving checkpoints for 1 into /tmp/output_dir/model.ckpt.\n",
"INFO:tensorflow:loss = 3.18835e+08, step = 1\n",
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Starting evaluation at 2017-05-18-02:28:37\n",
"INFO:tensorflow:Restoring parameters from /tmp/output_dir/model.ckpt-1\n",
"INFO:tensorflow:Evaluation [1/100]\n",
"INFO:tensorflow:Finished evaluation at 2017-05-18-02:28:37\n",
"INFO:tensorflow:Saving dict for global step 1: global_step = 1, loss = 1.43582e+08\n",
"INFO:tensorflow:Validation (step 1): loss = 1.43582e+08, global_step = 1\n",
"INFO:tensorflow:global_step/sec: 20.5355\n",
"INFO:tensorflow:loss = 4.21164e+07, step = 101 (4.870 sec)\n",
"INFO:tensorflow:global_step/sec: 118.296\n",
"INFO:tensorflow:loss = 3.19501e+07, step = 201 (0.845 sec)\n",
"INFO:tensorflow:global_step/sec: 129.594\n",
"INFO:tensorflow:loss = 8.01906e+07, step = 301 (0.778 sec)\n",
"INFO:tensorflow:global_step/sec: 112.126\n",
"INFO:tensorflow:loss = 4.19203e+07, step = 401 (0.885 sec)\n",
"INFO:tensorflow:global_step/sec: 123.946\n",
"INFO:tensorflow:loss = 4.79577e+07, step = 501 (0.807 sec)\n",
"INFO:tensorflow:global_step/sec: 123.068\n",
"INFO:tensorflow:loss = 6.31445e+07, step = 601 (0.813 sec)\n",
"INFO:tensorflow:global_step/sec: 124.585\n",
"INFO:tensorflow:loss = 4.18562e+07, step = 701 (0.802 sec)\n",
"INFO:tensorflow:global_step/sec: 124.402\n",
"INFO:tensorflow:loss = 4.22422e+07, step = 801 (0.804 sec)\n",
"INFO:tensorflow:global_step/sec: 127.149\n",
"INFO:tensorflow:loss = 3.59709e+07, step = 901 (0.786 sec)\n",
"INFO:tensorflow:global_step/sec: 124.612\n",
"INFO:tensorflow:loss = 3.05073e+07, step = 1001 (0.802 sec)\n",
"INFO:tensorflow:global_step/sec: 119.977\n",
"INFO:tensorflow:loss = 4.06392e+07, step = 1101 (0.843 sec)\n",
"INFO:tensorflow:global_step/sec: 118.837\n",
"INFO:tensorflow:loss = 3.96273e+07, step = 1201 (0.833 sec)\n",
"INFO:tensorflow:global_step/sec: 124.73\n",
"INFO:tensorflow:loss = 5.83794e+07, step = 1301 (0.801 sec)\n",
"INFO:tensorflow:global_step/sec: 117.193\n",
"INFO:tensorflow:loss = 2.31712e+07, step = 1401 (0.854 sec)\n",
"INFO:tensorflow:global_step/sec: 123.772\n",
"INFO:tensorflow:loss = 2.47854e+07, step = 1501 (0.808 sec)\n",
"INFO:tensorflow:global_step/sec: 121.554\n",
"INFO:tensorflow:loss = 2.69959e+07, step = 1601 (0.823 sec)\n",
"INFO:tensorflow:global_step/sec: 125.984\n",
"INFO:tensorflow:loss = 2.44264e+07, step = 1701 (0.794 sec)\n",
"INFO:tensorflow:global_step/sec: 121.942\n",
"INFO:tensorflow:loss = 3.27822e+07, step = 1801 (0.820 sec)\n",
"INFO:tensorflow:global_step/sec: 124.062\n",
"INFO:tensorflow:loss = 2.68355e+07, step = 1901 (0.806 sec)\n",
"INFO:tensorflow:global_step/sec: 126.735\n",
"INFO:tensorflow:loss = 3.12895e+07, step = 2001 (0.789 sec)\n",
"INFO:tensorflow:global_step/sec: 119.837\n",
"INFO:tensorflow:loss = 1.82017e+07, step = 2101 (0.835 sec)\n",
"INFO:tensorflow:global_step/sec: 130.215\n",
"INFO:tensorflow:loss = 3.53857e+07, step = 2201 (0.767 sec)\n",
"INFO:tensorflow:global_step/sec: 122.283\n",
"INFO:tensorflow:loss = 4.33676e+07, step = 2301 (0.818 sec)\n",
"INFO:tensorflow:global_step/sec: 121.716\n",
"INFO:tensorflow:loss = 2.25773e+07, step = 2401 (0.821 sec)\n",
"INFO:tensorflow:global_step/sec: 132.131\n",
"INFO:tensorflow:loss = 2.51927e+07, step = 2501 (0.757 sec)\n",
"INFO:tensorflow:global_step/sec: 121.687\n",
"INFO:tensorflow:loss = 1.48666e+07, step = 2601 (0.826 sec)\n",
"INFO:tensorflow:global_step/sec: 121.38\n",
"INFO:tensorflow:loss = 1.77214e+07, step = 2701 (0.821 sec)\n",
"INFO:tensorflow:global_step/sec: 120.194\n",
"INFO:tensorflow:loss = 2.67903e+07, step = 2801 (0.830 sec)\n",
"INFO:tensorflow:global_step/sec: 118.984\n",
"INFO:tensorflow:loss = 1.97603e+07, step = 2901 (0.841 sec)\n",
"INFO:tensorflow:global_step/sec: 121.729\n",
"INFO:tensorflow:loss = 3.27341e+07, step = 3001 (0.822 sec)\n",
"INFO:tensorflow:global_step/sec: 123.155\n",
"INFO:tensorflow:loss = 1.98052e+07, step = 3101 (0.812 sec)\n",
"INFO:tensorflow:global_step/sec: 122.353\n",
"INFO:tensorflow:loss = 2.83327e+07, step = 3201 (0.817 sec)\n",
"INFO:tensorflow:global_step/sec: 120.479\n",
"INFO:tensorflow:loss = 3.48686e+07, step = 3301 (0.830 sec)\n",
"INFO:tensorflow:global_step/sec: 119.914\n",
"INFO:tensorflow:loss = 1.57687e+07, step = 3401 (0.833 sec)\n",
"INFO:tensorflow:global_step/sec: 119.723\n",
"INFO:tensorflow:loss = 3.37787e+07, step = 3501 (0.836 sec)\n",
"INFO:tensorflow:global_step/sec: 117.654\n",
"INFO:tensorflow:loss = 1.89048e+07, step = 3601 (0.850 sec)\n",
"INFO:tensorflow:global_step/sec: 121.744\n",
"INFO:tensorflow:loss = 1.54444e+07, step = 3701 (0.826 sec)\n",
"INFO:tensorflow:global_step/sec: 125.56\n",
"INFO:tensorflow:loss = 2.89857e+07, step = 3801 (0.794 sec)\n",
"INFO:tensorflow:global_step/sec: 122.2\n",
"INFO:tensorflow:loss = 2.58254e+07, step = 3901 (0.816 sec)\n",
"INFO:tensorflow:global_step/sec: 119.617\n",
"INFO:tensorflow:loss = 2.41199e+07, step = 4001 (0.836 sec)\n",
"INFO:tensorflow:global_step/sec: 118.098\n",
"INFO:tensorflow:loss = 1.89337e+07, step = 4101 (0.846 sec)\n",
"INFO:tensorflow:global_step/sec: 119.541\n",
"INFO:tensorflow:loss = 2.81653e+07, step = 4201 (0.837 sec)\n",
"INFO:tensorflow:global_step/sec: 118.926\n",
"INFO:tensorflow:loss = 1.05359e+07, step = 4301 (0.841 sec)\n",
"INFO:tensorflow:global_step/sec: 117.887\n",
"INFO:tensorflow:loss = 2.06676e+07, step = 4401 (0.848 sec)\n",
"INFO:tensorflow:global_step/sec: 119.209\n",
"INFO:tensorflow:loss = 2.89711e+07, step = 4501 (0.839 sec)\n",
"INFO:tensorflow:global_step/sec: 121.083\n",
"INFO:tensorflow:loss = 1.81756e+07, step = 4601 (0.825 sec)\n",
"INFO:tensorflow:global_step/sec: 123.458\n",
"INFO:tensorflow:loss = 2.29722e+07, step = 4701 (0.811 sec)\n",
"INFO:tensorflow:global_step/sec: 119.553\n",
"INFO:tensorflow:loss = 2.18481e+07, step = 4801 (0.836 sec)\n",
"INFO:tensorflow:global_step/sec: 125.019\n",
"INFO:tensorflow:loss = 1.68649e+07, step = 4901 (0.799 sec)\n",
"INFO:tensorflow:global_step/sec: 123.658\n",
"INFO:tensorflow:loss = 2.78938e+07, step = 5001 (0.809 sec)\n",
"INFO:tensorflow:global_step/sec: 121.055\n",
"INFO:tensorflow:loss = 2.37118e+07, step = 5101 (0.825 sec)\n",
"INFO:tensorflow:global_step/sec: 124.397\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 1.80479e+07, step = 5201 (0.805 sec)\n",
"INFO:tensorflow:global_step/sec: 124.082\n",
"INFO:tensorflow:loss = 1.42421e+07, step = 5301 (0.806 sec)\n",
"INFO:tensorflow:global_step/sec: 115.894\n",
"INFO:tensorflow:loss = 2.45195e+07, step = 5401 (0.863 sec)\n",
"INFO:tensorflow:global_step/sec: 121.967\n",
"INFO:tensorflow:loss = 2.10585e+07, step = 5501 (0.820 sec)\n",
"INFO:tensorflow:global_step/sec: 121.443\n",
"INFO:tensorflow:loss = 1.59946e+07, step = 5601 (0.824 sec)\n",
"INFO:tensorflow:global_step/sec: 118.556\n",
"INFO:tensorflow:loss = 1.98039e+07, step = 5701 (0.845 sec)\n",
"INFO:tensorflow:global_step/sec: 117.499\n",
"INFO:tensorflow:loss = 1.51192e+07, step = 5801 (0.849 sec)\n",
"INFO:tensorflow:global_step/sec: 115.655\n",
"INFO:tensorflow:loss = 3.23047e+07, step = 5901 (0.864 sec)\n",
"INFO:tensorflow:global_step/sec: 119.006\n",
"INFO:tensorflow:loss = 2.65075e+07, step = 6001 (0.841 sec)\n",
"INFO:tensorflow:global_step/sec: 121.712\n",
"INFO:tensorflow:loss = 2.03057e+07, step = 6101 (0.822 sec)\n",
"INFO:tensorflow:global_step/sec: 122.988\n",
"INFO:tensorflow:loss = 1.98623e+07, step = 6201 (0.813 sec)\n",
"INFO:tensorflow:global_step/sec: 119.101\n",
"INFO:tensorflow:loss = 1.64578e+07, step = 6301 (0.840 sec)\n",
"INFO:tensorflow:global_step/sec: 118.79\n",
"INFO:tensorflow:loss = 1.26528e+07, step = 6401 (0.842 sec)\n",
"INFO:tensorflow:global_step/sec: 115.122\n",
"INFO:tensorflow:loss = 1.27203e+07, step = 6501 (0.869 sec)\n",
"INFO:tensorflow:global_step/sec: 122\n",
"INFO:tensorflow:loss = 2.51296e+07, step = 6601 (0.820 sec)\n",
"INFO:tensorflow:global_step/sec: 117.994\n",
"INFO:tensorflow:loss = 3.57162e+07, step = 6701 (0.848 sec)\n",
"INFO:tensorflow:global_step/sec: 122.801\n",
"INFO:tensorflow:loss = 2.07559e+07, step = 6801 (0.814 sec)\n",
"INFO:tensorflow:global_step/sec: 118.899\n",
"INFO:tensorflow:loss = 2.02879e+07, step = 6901 (0.842 sec)\n",
"INFO:tensorflow:global_step/sec: 120.236\n",
"INFO:tensorflow:loss = 8.61477e+06, step = 7001 (0.831 sec)\n",
"INFO:tensorflow:global_step/sec: 120.851\n",
"INFO:tensorflow:loss = 2.15346e+07, step = 7101 (0.827 sec)\n",
"INFO:tensorflow:global_step/sec: 129.997\n",
"INFO:tensorflow:loss = 2.13486e+07, step = 7201 (0.771 sec)\n",
"INFO:tensorflow:global_step/sec: 117.11\n",
"INFO:tensorflow:loss = 1.58869e+07, step = 7301 (0.854 sec)\n",
"INFO:tensorflow:global_step/sec: 128.525\n",
"INFO:tensorflow:loss = 2.14093e+07, step = 7401 (0.779 sec)\n",
"INFO:tensorflow:global_step/sec: 126.143\n",
"INFO:tensorflow:loss = 2.37592e+07, step = 7501 (0.791 sec)\n",
"INFO:tensorflow:global_step/sec: 120.863\n",
"INFO:tensorflow:loss = 2.27634e+07, step = 7601 (0.828 sec)\n",
"INFO:tensorflow:global_step/sec: 113.427\n",
"INFO:tensorflow:loss = 3.10648e+07, step = 7701 (0.881 sec)\n",
"INFO:tensorflow:global_step/sec: 119.571\n",
"INFO:tensorflow:loss = 2.08745e+07, step = 7801 (0.836 sec)\n",
"INFO:tensorflow:global_step/sec: 128.025\n",
"INFO:tensorflow:loss = 2.24044e+07, step = 7901 (0.781 sec)\n",
"INFO:tensorflow:global_step/sec: 121.197\n",
"INFO:tensorflow:loss = 2.12339e+07, step = 8001 (0.828 sec)\n",
"INFO:tensorflow:global_step/sec: 124.79\n",
"INFO:tensorflow:loss = 2.23047e+07, step = 8101 (0.801 sec)\n",
"INFO:tensorflow:global_step/sec: 124.69\n",
"INFO:tensorflow:loss = 2.48484e+07, step = 8201 (0.800 sec)\n",
"INFO:tensorflow:global_step/sec: 122.447\n",
"INFO:tensorflow:loss = 3.00606e+07, step = 8301 (0.819 sec)\n",
"INFO:tensorflow:global_step/sec: 125.032\n",
"INFO:tensorflow:loss = 2.62958e+07, step = 8401 (0.802 sec)\n",
"INFO:tensorflow:global_step/sec: 124.911\n",
"INFO:tensorflow:loss = 2.19767e+07, step = 8501 (0.797 sec)\n",
"INFO:tensorflow:global_step/sec: 120.855\n",
"INFO:tensorflow:loss = 2.58696e+07, step = 8601 (0.828 sec)\n",
"INFO:tensorflow:global_step/sec: 122.078\n",
"INFO:tensorflow:loss = 3.12598e+07, step = 8701 (0.819 sec)\n",
"INFO:tensorflow:global_step/sec: 123.366\n",
"INFO:tensorflow:loss = 2.26468e+07, step = 8801 (0.811 sec)\n",
"INFO:tensorflow:global_step/sec: 115.682\n",
"INFO:tensorflow:loss = 2.3405e+07, step = 8901 (0.863 sec)\n",
"INFO:tensorflow:global_step/sec: 118.603\n",
"INFO:tensorflow:loss = 1.89545e+07, step = 9001 (0.844 sec)\n",
"INFO:tensorflow:global_step/sec: 121.888\n",
"INFO:tensorflow:loss = 1.80466e+07, step = 9101 (0.821 sec)\n",
"INFO:tensorflow:global_step/sec: 116.303\n",
"INFO:tensorflow:loss = 2.86328e+07, step = 9201 (0.859 sec)\n",
"INFO:tensorflow:global_step/sec: 119.984\n",
"INFO:tensorflow:loss = 1.39935e+07, step = 9301 (0.832 sec)\n",
"INFO:tensorflow:global_step/sec: 120.686\n",
"INFO:tensorflow:loss = 1.27423e+07, step = 9401 (0.832 sec)\n",
"INFO:tensorflow:global_step/sec: 127.189\n",
"INFO:tensorflow:loss = 1.76635e+07, step = 9501 (0.784 sec)\n",
"INFO:tensorflow:global_step/sec: 120.85\n",
"INFO:tensorflow:loss = 1.24075e+07, step = 9601 (0.828 sec)\n",
"INFO:tensorflow:global_step/sec: 127.394\n",
"INFO:tensorflow:loss = 2.11293e+07, step = 9701 (0.785 sec)\n",
"INFO:tensorflow:global_step/sec: 129.532\n",
"INFO:tensorflow:loss = 2.34291e+07, step = 9801 (0.772 sec)\n",
"INFO:tensorflow:global_step/sec: 119.468\n",
"INFO:tensorflow:loss = 2.34618e+07, step = 9901 (0.837 sec)\n",
"INFO:tensorflow:Saving checkpoints for 10000 into /tmp/output_dir/model.ckpt.\n",
"INFO:tensorflow:Loss for final step: 2.59231e+07.\n",
"WARNING:tensorflow:From /usr/local/tensorflow/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:625: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.\n",
"Instructions for updating:\n",
"Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.\n",
"INFO:tensorflow:Starting evaluation at 2017-05-18-02:30:04\n",
"INFO:tensorflow:Restoring parameters from /tmp/output_dir/model.ckpt-10000\n",
"INFO:tensorflow:Evaluation [1/100]\n",
"INFO:tensorflow:Finished evaluation at 2017-05-18-02:30:05\n",
"INFO:tensorflow:Saving dict for global step 10000: global_step = 10000, loss = 8.2764e+06\n"
]
},
{
"data": {
"text/plain": [
"({'global_step': 10000, 'loss': 8276404.5}, [])"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import shutil\n",
"shutil.rmtree(\"/tmp/output_dir\", ignore_errors=True)\n",
"tf.contrib.learn.learn_runner.run(experiment_fn, run_config=tf.contrib.learn.RunConfig(model_dir=\"/tmp/output_dir\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
@seanmb
Copy link

seanmb commented May 19, 2017

Hi, the dnnregressor is not working for me. I get the following error: ValueError:

Dimension size must be evenly divisible by 5 but is 64 for 'dnn/input_from_feature_columns/input_layer/body-style_indicator/Reshape' (op: 'Reshape') with input shapes: [64], [2] and with input tensors computed as partial shapes: input[1] = [?,5].

@alain2208
Copy link

same as seanmb on windows cpu on the dnnregressor.fit(input_fn=training_input_fn, steps=10000)

@nnwanwa
Copy link

nnwanwa commented May 19, 2017

In the talk, Martin mentioned that the code was written for Tensorflow 1.2, and wouldn't work with earlier versions. So my guess is that you may be using an earlier version...

@matejurbasik
Copy link

I have the same problem. I am sure I have tensorflow 1.2

I am new to ML and I miss on every tutorial, even this one, example how to use it. How can I manually input new car's params and get estimated output?

@veravira
Copy link

same issue

@asuslov
Copy link

asuslov commented May 25, 2017

the error has already been fixed in source
tensorflow/tensorflow@5c1949e

@winklerj
Copy link

@seanmb I had a similar issue when I was using a numeric column and accidentally had the shape parameter set. In your case it looks like body_style is set to an int64 (which is the 64 in the error) but you are specifying something like tf.feature_column.numeric_column('body-style',5). Drop the 5 and it should resolve this error.

@shmalex
Copy link

shmalex commented Dec 20, 2017

Hi, thanks for article. can you please help me understand how to use that model? simple code sample? many thanks.

@joepareti54
Copy link

if I don't have jupiter notebook (in my case I work in Azure and have no graphics), can I put all the lines of code in one text file and run through it? How?

@hmz17
Copy link

hmz17 commented Oct 27, 2018

if I don't have jupiter notebook (in my case I work in Azure and have no graphics), can I put all the lines of code in one text file and run through it? How?

Try using Google CoLab, its free online Jupyter Notebook

@joepareti54
Copy link

I have put the code in one file called code.py which I pass as input to python(3). The job terminates without any output, but with the following messages. Anything I can do to fix?

WARNING:tensorflow:Using temporary folder as model directory: /home/u23885/tmp/tmpzouq5h7f
WARNING:tensorflow:RunConfig.uid (from tensorflow.contrib.learn.python.learn.estimators.run_config) is experimental and may change or be removed at any time, and without warning.
WARNING:tensorflow:RunConfig.uid (from tensorflow.contrib.learn.python.learn.estimators.run_config) is experimental and may change or be removed at any time, and without warning.
WARNING:tensorflow:From /home/u23885/.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/monitors.py:267: BaseMonitor.init (from tensorflow.contrib.learn.python.learn.monitors) is deprecated and will be removed after 2016-12-05.
Instructions for updating:
Monitors are deprecated. Please use tf.train.SessionRunHook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment