-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.py
34 lines (30 loc) · 1.22 KB
/
script.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
import apdt
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
import os
gas_type = 'pm2d5'
if os.path.exists('data/nanjing'+gas_type+'.pkl'):
dataset = apdt.ml.DataSet('data/nanjing'+gas_type+'.pkl')
else:
site_list = ['115'+str(i)+'A' for i in range(1,10)]
feature_list = ['wendu', 'shidu', 'fengsu', 'fengxiang', 'qiya']
a = apdt.io.load_weather('1151A','2017-01-01','2020-04-15',feature=feature_list)
b = apdt.io.load_nms(site_list,'2017-01-01','2020-04-15',gas=gas_type)
c = b.merge(a)
c = apdt.proc.spatial_interplot(c,'IDW','ALL')
c = apdt.proc.temporal_interpolate(c)
# Construct dataset
dataset = apdt.ml.DataSet(c, method='window', seq_len=730, normalize_method='999pt')
print(c.normalize_factor)
dataset.dump('data/nanjing'+gas_type+'.pkl')
# Define the model structure
class MyModel(apdt.ml.TFModel):
def def_model(self, **kwarg):
self.input = tf.placeholder(tf.float32, shape=(1, 9, 730, 6))
self.learning_rate = tf.placeholder(tf.float32, name='learning_rate')
self.pred, self.loss = apdt.ml.WaveNet(self.input[0,:,:], name='wavenet')
# Set up the model
model = MyModel()
# Start Training
model.fit(dataset, baseline=10.0, epoch=150)