You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError: Initializer for variable conv2d_2/kernel/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or conditional, use a lambda as the initializer.
#31
Open
SadAngelF opened this issue
Dec 15, 2018
· 1 comment
when I run the run.ipynb in jupyter. I get the things in the following:
ValueError Traceback (most recent call last)
in
22
23 # create an untrained neural network objects from the config file
---> 24 current_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape, env.action_size, config.HIDDEN_CNN_LAYERS)
25 best_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape, env.action_size, config.HIDDEN_CNN_LAYERS)
26
~/miniconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in _init_from_args(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, expected_shape, constraint)
385 "construct, such as a loop or conditional. When creating a "
386 "variable inside a loop or conditional, use a lambda as the "
--> 387 "initializer." % name)
388 # pylint: enable=protected-access
389 shape = (self._initial_value.get_shape()
ValueError: Initializer for variable conv2d_2/kernel/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or conditional, use a lambda as the initializer.
The text was updated successfully, but these errors were encountered:
when I run the run.ipynb in jupyter. I get the things in the following:
ValueError Traceback (most recent call last)
in
22
23 # create an untrained neural network objects from the config file
---> 24 current_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape, env.action_size, config.HIDDEN_CNN_LAYERS)
25 best_NN = Residual_CNN(config.REG_CONST, config.LEARNING_RATE, (2,) + env.grid_shape, env.action_size, config.HIDDEN_CNN_LAYERS)
26
~/DeepReinforcementLearning-master/model.py in init(self, reg_const, learning_rate, input_dim, output_dim, hidden_layers)
112 self.hidden_layers = hidden_layers
113 self.num_layers = len(hidden_layers)
--> 114 self.model = self._build_model()
115
116 def residual_layer(self, input_block, filters, kernel_size):
~/DeepReinforcementLearning-master/model.py in _build_model(self)
223 main_input = Input(shape = self.input_dim, name = 'main_input')
224
--> 225 x = self.conv_layer(main_input, self.hidden_layers[0]['filters'], self.hidden_layers[0]['kernel_size'])
226
227 if len(self.hidden_layers) > 1:
~/DeepReinforcementLearning-master/model.py in conv_layer(self, x, filters, kernel_size)
146 , activation='linear'
147 , kernel_regularizer = regularizers.l2(self.reg_const)
--> 148 )(x)
149
150 x = BatchNormalization(axis=1)(x)
~/miniconda3/envs/py36/lib/python3.6/site-packages/keras/engine/base_layer.py in call(self, inputs, **kwargs)
429 'You can build it manually via: '
430 '
layer.build(batch_input_shape)
')--> 431 self.build(unpack_singleton(input_shapes))
432 self.built = True
433
~/miniconda3/envs/py36/lib/python3.6/site-packages/keras/layers/convolutional.py in build(self, input_shape)
139 name='kernel',
140 regularizer=self.kernel_regularizer,
--> 141 constraint=self.kernel_constraint)
142 if self.use_bias:
143 self.bias = self.add_weight(shape=(self.filters,),
~/miniconda3/envs/py36/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your
' + object_name + '
call to the ' +90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
~/miniconda3/envs/py36/lib/python3.6/site-packages/keras/engine/base_layer.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint)
250 dtype=dtype,
251 name=name,
--> 252 constraint=constraint)
253 if regularizer is not None:
254 with K.name_scope('weight_regularizer'):
~/miniconda3/envs/py36/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in variable(value, dtype, name, constraint)
400 v._uses_learning_phase = False
401 return v
--> 402 v = tf.Variable(value, dtype=tf.as_dtype(dtype), name=name)
403 if isinstance(value, np.ndarray):
404 v._keras_shape = value.shape
~/miniconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in init(self, initial_value, trainable, collections, validate_shape, caching_device, name, variable_def, dtype, expected_shape, import_scope, constraint)
257 dtype=dtype,
258 expected_shape=expected_shape,
--> 259 constraint=constraint)
260
261 def repr(self):
~/miniconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in _init_from_args(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, expected_shape, constraint)
385 "construct, such as a loop or conditional. When creating a "
386 "variable inside a loop or conditional, use a lambda as the "
--> 387 "initializer." % name)
388 # pylint: enable=protected-access
389 shape = (self._initial_value.get_shape()
ValueError: Initializer for variable conv2d_2/kernel/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or conditional, use a lambda as the initializer.
The text was updated successfully, but these errors were encountered: