-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstModel.py
More file actions
43 lines (33 loc) · 1.2 KB
/
FirstModel.py
File metadata and controls
43 lines (33 loc) · 1.2 KB
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
37
38
39
40
41
42
43
import tensorflow as tf;
import numpy as np;
def FirstModel(options):
# Setup random dataset
x = np.arange(1, 101, step=0.1)
y = [X**2 for X in x]
x = tf.cast(tf.constant(x), dtype=tf.float32)
y = tf.cast(tf.constant(y), dtype=tf.float32)
# Created a simple model with an single feature and single output
model = tf.keras.models.Sequential()
# Output Layer
model.add(tf.keras.layers.Dense(units=1, input_shape=(1,)))
learning_rate = 0.03
ecpoch = 100
batch_size = None
saveModel = False
loadModel = False
if options is not None:
print(options)
if options.learningRate is not None:
learning_rate = options.learningRate
if options.batchSize is not None:
batch_size = options.batchSize
if options.epochs is not None:
saveModel = options.epochs
loadModel = options.loadModel
saveModel = options.saveModel
model.compile(optimizer=tf.keras.optimizers.RMSprop(learning_rate),
loss = "mean_squared_error",
metrics=[tf.keras.metrics.RootMeanSquaredError()])
model.fit(x,y, epochs= ecpoch)
if __name__ == "__main__":
FirstModel(None)