backstopmedia / tensorflowbook

459 stars 297 forks source link

Chapter 5 code errors in cnn sample #19

Open JohnFarl opened 7 years ago

JohnFarl commented 7 years ago

I have already fixed some errors by myself however the way how parameters are passed in this method seems wrong and I get the error got an unexpected keyword argument

layer_one = tf.contrib.layers.convolution2d( float_image_batch, num_output_channels=32,
kernel_size=(5,5),
activation_fn=tf.nn.relu, weight_init=tf.random_normal, stride=(2, 2), trainable=True)

More details on my Stackoverflow question http://stackoverflow.com/questions/41539658/tensorflow-error-when-i-try-to-use-tf-contrib-layers-convolution2d/41540092#41540092

irwenqiang commented 7 years ago
      conv2d_layer_one = tf.contrib.layers.convolution2d(                
      float_image_batch,                  
      #num_output_channels=32,     # The number of filters to generate               
      num_outputs=32,           
      kernel_size=(5,5),                     # It's only the filter height and width.          
      activation_fn=tf.nn.relu,        
      #weight_init=tf.random_normal,         
      weights_initializer=tf.random_normal_initializer(),        
      stride=(2, 2),        
      trainable=True)       

my updated code seems OK.
The version of tf used in book is 0.8.0 as mentioned in requirements, my version is latest 0.12.0.