nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook
https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition
MIT License
6.23k stars 2.41k forks source link

Introductory CNN Model: TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64 #153

Open femosh opened 5 years ago

femosh commented 5 years ago

This generate the TypeError: full2_weight = tf.Variable(tf.truncated_normal([fully_connected_size1, target_size], stddev=0.1, dtype=tf.float32)) full2_bias = tf.Variable(tf.truncated_normal([target_size], stddev=0.1, dtype=tf.float32))

target_size is wrong, it is 2.0 instead of 10 (9+1). However, the problem originated from: from tensorflow.examples.tutorials.mnist import input_data

Use this to fix the problem: from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets data_dir = 'temp' mnist = input_data.read_data_sets(data_dir, one_hot=True)

data_dir = 'temp' mnist = read_data_sets(data_dir)