Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/reviews/implementations/models/sentiment_dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
def create_estimator(run_config, model_config):
hparams = model_config["hparams"]
vocab_size = len(model_config["aggregates"]["reviews_vocab"])
max_review_length = model_config["aggregates"]["max_review_length"]

def model_fn(features, labels, mode, params):
embedding_input = features["embedding_input"]
embedding_input = tf.reshape(embedding_input, [-1, max_review_length])
model = keras.Sequential()
model.add(keras.layers.Embedding(vocab_size, 16))
model.add(keras.layers.GlobalAveragePooling1D())
Expand All @@ -36,6 +34,7 @@ def model_fn(features, labels, mode, params):
loss=loss,
train_op=optimizer.minimize(loss, tf.train.get_or_create_global_step()),
)

if mode is tf.estimator.ModeKeys.EVAL:
logits = model(embedding_input, training=False)
loss = tf.losses.sparse_softmax_cross_entropy(labels=labels, logits=logits)
Expand Down
1 change: 0 additions & 1 deletion examples/reviews/resources/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
- embedding_input
aggregates:
- reviews_vocab
- max_review_length
hparams:
learning_rate: 0.01
data_partition_ratio:
Expand Down