Skip to content

Does not work with tensorflow-gpu #29

Open

Description

@Vovak1919

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)

Activity

  1. Vovak1919 commented on Dec 7, 2018

    @Vovak1919
    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

  2. Vovak1919 commented on Dec 7, 2018

    @Vovak1919
    Author

    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)

  3. acautin commented on Dec 7, 2018

    @acautin

    @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

  4. Vovak1919 commented on Dec 7, 2018

    @Vovak1919
    Author

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

  5. ahmedosama9777 commented on Apr 27, 2020

    @ahmedosama9777

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions