Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with tensorflow-gpu #29

Open
Vovak1919 opened this issue Dec 7, 2018 · 5 comments
Open

Does not work with tensorflow-gpu #29

Vovak1919 opened this issue Dec 7, 2018 · 5 comments

Comments

@Vovak1919
Copy link

Vovak1919 commented Dec 7, 2018

After installing tensorflow-gpu, errors appeared in the model.py module:
Line 138

	def conv_layer(self, x, filters, kernel_size):
		x = Conv2D(
		filters = filters
		, kernel_size = kernel_size
		, data_format="channels_first"
		, padding = 'same'
		, use_bias=False
		, activation='linear'
		, kernel_regularizer = regularizers.l2(self.reg_const)
		)(x)
		x = BatchNormalization(axis=1)(x)

150 x = BatchNormalization(axis=1)(x)
^
ValueError
Shape must be rank 1 but is rank 0 for 'batch_normalization_1/cond/Reshape_4' (op: 'Reshape') with input shapes: [1,75,1,1], [].
File "C:\DRL\model.py", line 150, in conv_layer
x = BatchNormalization(axis=1)(x)
File "C:\DRL\model.py", line 225, in _build_model
x = self.conv_layer(main_input, self.hidden_layers[0]['filters'], self.hidden_layers[0]['kernel_size'])
File "C:\DRL\model.py", line 114, in init
self.model = self._build_model()
File "C:\DRL\Untitled-1.py", line 67, in
current_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape, env.action_size, config.HIDDEN_CNN_LAYERS)

@Vovak1919
Copy link
Author

Shape:TensorShape([Dimension(None), Dimension(75), Dimension(6), Dimension(7)])
dims:[Dimension(None), Dimension(75), Dimension(6), Dimension(7)]
0:Dimension(None)
1:Dimension(75)
2:Dimension(6)
3:Dimension(7)
len:4
ndims:4
_dims:[Dimension(None), Dimension(75), Dimension(6), Dimension(7)]
_ndims:4
_tf_api_names:('TensorShape',)
_tf_api_names_v1:('TensorShape',)
value_index:0
_consumers:[]
_dtype:tf.float32
_id:21

@Vovak1919
Copy link
Author

Vovak1919 commented Dec 7, 2018

The module is called from here.

# create an untrained neural network objects from the config file
current_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape,   env.action_size, config.HIDDEN_CNN_LAYERS)

Call Stack:
conv_layer (c:\DRL\model.py:150)
_build_model (c:\DRL\model.py:225)
init (c:\DRL\model.py:114)
(c:\DRL\Untitled-1.py:67)

@acautin
Copy link

acautin commented Dec 7, 2018

@Vovak1919 at least for

Shape must be rank 1 but is rank 0 for 'batch_normalization_1/cond/Reshape_4' (op: 'Reshape') with input shapes: [1,75,1,1], [].

It seems to be a problem with keras, the version 2.1.5 worked for me. (It should also be solved on master but not yet on the pip version)

Ref: keras-team/keras#10648

@Vovak1919
Copy link
Author

Vovak1919 commented Dec 7, 2018

Thank you, earned after correcting the file tensorflow_backend.py
keras-team/keras@e3a2f7d

@ahmedosama9777
Copy link

What did you do as a correction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants