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
I tried to run the example code below and receive the following error: model = tf.keras.Sequential( layers=tf.keras.layers.Dense(units=2), name="Linear") model.compile(loss=tf.keras.losses.MeanSquaredError(), optimizer="adam") ImportanceTraining(model).fit( x_train, y_train, batch_size=32, epochs=10, verbose=1,validation_data=(x_val, y_val) )
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/model_wrappers.py in init(self, model, reweighting, score, layer)
167 # Augment the model with reweighting, scoring etc
168 # Save the new model and the training functions in member variables
--> 169 self._augment_model(model, score, reweighting)
170
171 def _gnorm_layer(self, model, layer):
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/model_wrappers.py in _augment_model(self, model, score, reweighting)
203 loss = model.loss
204 optimizer = model.optimizer.class(**model.optimizer.get_config())
--> 205 output_shape = model.get_output_shape_at(0)[1:]
206 if isinstance(loss, str) and loss.startswith("sparse"):
207 output_shape = output_shape[:-1] + (1,)
~/myvenv/mykears3.9/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py in get_output_shape_at(self, node_index)
1986 RuntimeError: If called in Eager mode.
1987 """
-> 1988 return self._get_node_attribute_at_index(node_index, 'output_shapes',
1989 'output shape')
1990
~/myvenv/mykears3.9/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py in _get_node_attribute_at_index(self, node_index, attr, attr_name)
2582 """
2583 if not self._inbound_nodes:
-> 2584 raise RuntimeError('The layer has never been called '
2585 'and thus has no defined ' + attr_name + '.')
2586 if not len(self._inbound_nodes) > node_index:
RuntimeError: The layer has never been called and thus has no defined output shape.
`
The text was updated successfully, but these errors were encountered:
I tried to run the example code below and receive the following error:
model = tf.keras.Sequential( layers=tf.keras.layers.Dense(units=2), name="Linear") model.compile(loss=tf.keras.losses.MeanSquaredError(), optimizer="adam")
ImportanceTraining(model).fit( x_train, y_train, batch_size=32, epochs=10, verbose=1,validation_data=(x_val, y_val) )
The error is below:
`---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in
----> 1 ImportanceTraining(model).fit(
2 x_train, y_train,
3 batch_size=32,
4 epochs=10,
5 verbose=1,validation_data=(x_val, y_val)
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/training.py in init(self, model, presample, tau_th, forward_batch_size, score, layer)
368
369 # Call the parent to wrap the model
--> 370 super(ImportanceTraining, self).init(model, score, layer)
371
372 def sampler(self, dataset, batch_size, steps_per_epoch, epochs):
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/training.py in init(self, model, score, layer)
338 self._reweighting = BiasedReweightingPolicy(1.0) # no bias
339
--> 340 super(_UnbiasedImportanceTraining, self).init(model, score, layer)
341
342 @Property
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/training.py in init(self, model, score, layer)
33 self._check_model(model)
34 self.original_model = model
---> 35 self.model = OracleWrapper(
36 model,
37 self.reweighting,
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/model_wrappers.py in init(self, model, reweighting, score, layer)
167 # Augment the model with reweighting, scoring etc
168 # Save the new model and the training functions in member variables
--> 169 self._augment_model(model, score, reweighting)
170
171 def _gnorm_layer(self, model, layer):
~/myvenv/mykears3.9/lib/python3.9/site-packages/importance_sampling/model_wrappers.py in _augment_model(self, model, score, reweighting)
203 loss = model.loss
204 optimizer = model.optimizer.class(**model.optimizer.get_config())
--> 205 output_shape = model.get_output_shape_at(0)[1:]
206 if isinstance(loss, str) and loss.startswith("sparse"):
207 output_shape = output_shape[:-1] + (1,)
~/myvenv/mykears3.9/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py in get_output_shape_at(self, node_index)
1986 RuntimeError: If called in Eager mode.
1987 """
-> 1988 return self._get_node_attribute_at_index(node_index, 'output_shapes',
1989 'output shape')
1990
~/myvenv/mykears3.9/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py in _get_node_attribute_at_index(self, node_index, attr, attr_name)
2582 """
2583 if not self._inbound_nodes:
-> 2584 raise RuntimeError('The layer has never been called '
2585 'and thus has no defined ' + attr_name + '.')
2586 if not len(self._inbound_nodes) > node_index:
RuntimeError: The layer has never been called and thus has no defined output shape.
`
The text was updated successfully, but these errors were encountered: