Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
Calling the parent constructor is needed, otherwise it will fail with the following error:
RuntimeError: It looks like you are subclassing `Model` and you forgot to call `super(YourClass, self).__init__()`. Always start with this line.
PiperOrigin-RevId: 207823589
  • Loading branch information
wangtz authored and tensorflower-gardener committed Aug 8, 2018
1 parent be9e098 commit 38e507f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tensorflow/python/keras/engine/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Model(Network):
class MyModel(tf.keras.Model):
def __init__(self):
super(MyModel, self).__init__()
self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu)
self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax)
Expand All @@ -94,6 +95,7 @@ def call(self, inputs):
class MyModel(tf.keras.Model):
def __init__(self):
super(MyModel, self).__init__()
self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu)
self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax)
self.dropout = tf.keras.layers.Dropout(0.5)
Expand Down

0 comments on commit 38e507f

Please sign in to comment.