-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_test.py
45 lines (31 loc) · 1.22 KB
/
model_test.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
37
38
39
40
41
42
43
44
45
import h5py
import numpy as np
import tensorflow as tf
# ----------------------------------------------------------------------
fname = 'model.h5'
print('Reading:', fname)
model = tf.keras.models.load_model(fname)
model.summary()
# ----------------------------------------------------------------------
fname = 'bolo_data.h5'
print('Reading:', fname)
f = h5py.File(fname, 'r+')
# ----------------------------------------------------------------------
for pulse in f:
g = f[pulse]
bolo = np.clip(g['bolo'][:], 0., None)/1e6
bolo_t = g['bolo_t'][:]
print('%-10s %-10s %-20s %-10s' % (pulse, 'bolo', bolo.shape, bolo.dtype))
print('%-10s %-10s %-20s %-10s' % (pulse, 'bolo_t', bolo_t.shape, bolo_t.dtype))
tomo = model.predict(bolo, batch_size=1000, verbose=1)*1e6
tomo_t = bolo_t
print('%-10s %-10s %-20s %-10s' % (pulse, 'tomo', tomo.shape, tomo.dtype))
print('%-10s %-10s %-20s %-10s' % (pulse, 'tomo_t', tomo_t.shape, tomo_t.dtype))
if 'tomo' in g:
del g['tomo']
if 'tomo_t' in g:
del g['tomo_t']
g.create_dataset('tomo', data=tomo)
g.create_dataset('tomo_t', data=tomo_t)
# ----------------------------------------------------------------------
f.close()