-
Notifications
You must be signed in to change notification settings - Fork 1
/
modeling.py
36 lines (30 loc) · 999 Bytes
/
modeling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import tensorflow as tf
class MySequentialModel(tf.keras.Model):
def __init__(
self,
out_size: int,
units: int,
**kwargs
):
super().__init__(**kwargs)
self.dense_1 = tf.keras.layers.Dense(units=units, activation='relu')
self.dense_2 = tf.keras.layers.Dense(units=units, activation='relu')
self.output_layer = tf.keras.layers.Dense(
units=out_size, activation='softmax')
def call(self, x):
x = self.dense_1(x)
# x = self.dense_2(x)
return self.output_layer(x)
class CrossProductOutputModel(tf.keras.Model):
def __init__(
self,
out_size: int,
units: int,
**kwargs
):
super().__init__(**kwargs)
self.dense_1 = tf.keras.layers.Dense(units=units, activation='relu')
self.dense_2 = tf.keras.layers.Dense(
units=out_size, activation='sigmoid')
def call(self, x):
return self.dense_2(self.dense_1(x))