-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
23 lines (19 loc) · 842 Bytes
/
model.py
File metadata and controls
23 lines (19 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from model_zoo.model import BaseModel
import tensorflow as tf
class DenseModel(BaseModel):
def __init__(self, config):
super(DenseModel, self).__init__(config)
self.embedding = tf.keras.layers.Embedding(config['vocab_size'], config['embedding_size'])
self.pool = tf.keras.layers.GlobalAveragePooling1D()
self.dense1 = tf.keras.layers.Dense(16, activation=tf.nn.relu)
self.dense2 = tf.keras.layers.Dense(1, activation=tf.nn.sigmoid)
def call(self, inputs, training=None, mask=None):
o = self.embedding(inputs)
o = self.pool(o)
o = self.dense1(o)
o = self.dense2(o)
return o
def init(self):
self.compile(optimizer=tf.train.AdamOptimizer(),
loss='binary_crossentropy',
metrics=['accuracy'])