-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
26 lines (20 loc) · 861 Bytes
/
train.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
#!/usr/bin/env python
import numpy as np
from model import Net
# Hyperparams
input_dim = 1
latent_dim = 100
output_dim = 1
inputs = np.array([[3.3], [4.4], [5.5], [6.71], [6.93], [4.168],
[9.779], [6.182], [7.59], [2.167], [7.042],
[10.791], [5.313], [7.997], [3.1]], dtype=np.float32)
targets = np.array([[1.7], [2.76], [2.09], [3.19], [1.694], [1.573],
[3.366], [2.596], [2.53], [1.221], [2.827],
[3.465], [1.65], [2.904], [1.3]], dtype=np.float32)
num_epochs = 1000
model = Net(input_dim, latent_dim, output_dim)
for epoch in range(num_epochs):
preds = model.train(inputs, targets)
if epoch%1==0:
print(epoch, "\tMSELoss is: ", np.sum((preds - targets)**2))
print("===>>> Preds are: \n{}\n===>>> Targets are: \n{}".format(model.getPreds(inputs), targets))