Closed xin-xinhanggao closed 8 years ago
The model assumes theano dimension ordering. You have a few options:
Please confirm if that solved the problem. If so I will add it to the REDAME.
Thanks for your reply.
The first method works!
But the second one fails.
When I type the command, I see this
Using TensorFlow backend.
('Epoch is', 0)
('Number of batches', 1875)
Traceback (most recent call last):
File "dcgan.py", line 167, in
Ok, probably another place in the code that requires changing to work with tensorflow.
Maybe should also change this line: model.add(Reshape((128, 7, 7), input_shape=(128_7_7,)))
Updated the readme with the theano dimension ordering requirment, closing this issue.
When I type python dcgan.py --mode train --batch_size 32, I will see this File "dcgan.py", line 167, in
train(BATCH_SIZE=args.batch_size)
File "dcgan.py", line 80, in train
discriminator = discriminator_model()
File "dcgan.py", line 41, in discriminator_model
model.add(MaxPooling2D(pool_size=(2, 2)))
File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 312, in add
output_tensor = layer(self.outputs[0])
File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 514, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 149, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/usr/local/lib/python2.7/site-packages/keras/layers/pooling.py", line 162, in call
dim_ordering=self.dim_ordering)
File "/usr/local/lib/python2.7/site-packages/keras/layers/pooling.py", line 212, in _pooling_function
border_mode, dim_ordering, pool_mode='max')
File "/usr/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1761, in pool2d
x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 850, in max_pool
name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1440, in _max_pool
data_format=data_format, name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2382, in create_op
set_shapes_for_outputs(ret)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1783, in set_shapes_for_outputs
shapes = shape_func(op)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 596, in call_cpp_shape_fn
raise ValueError(err.message)
ValueError: Negative dimension size caused by subtracting 2 from 1
I wonder how to fix it.