Skip to content

Commit fd82b04

Browse files
pruned and non pruned model
1 parent bb7e100 commit fd82b04

File tree

96 files changed

+2811
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2811
-1317
lines changed

AE.ipynb

-617
This file was deleted.

AE_compressed.ipynb

+1,612
Large diffs are not rendered by default.

AE_denois.ipynb

-700
This file was deleted.

AE_non_compressed.ipynb

+1,086
Large diffs are not rendered by default.

callbacks.py

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
'''
2+
Created on 7 Apr 2017
3+
4+
@author: jkiesele
5+
'''
6+
from __future__ import print_function
7+
8+
9+
from tensorflow.keras.callbacks import Callback, EarlyStopping,History,ModelCheckpoint,TensorBoard,ReduceLROnPlateau
10+
# loss per epoch
11+
from time import time
12+
from pdb import set_trace
13+
import json
14+
15+
class newline_callbacks_begin(Callback):
16+
17+
def __init__(self,outputDir):
18+
self.outputDir=outputDir
19+
self.loss=[]
20+
self.val_loss=[]
21+
self.full_logs=[]
22+
23+
def on_epoch_end(self,epoch, epoch_logs={}):
24+
import os
25+
lossfile=os.path.join( self.outputDir, 'losses.log')
26+
print('\n***callbacks***\nsaving losses to '+lossfile)
27+
self.loss.append(epoch_logs.get('loss'))
28+
self.val_loss.append(epoch_logs.get('val_loss'))
29+
f = open(lossfile, 'w')
30+
for i in range(len(self.loss)):
31+
f.write(str(self.loss[i]))
32+
f.write(" ")
33+
f.write(str(self.val_loss[i]))
34+
f.write("\n")
35+
f.close()
36+
normed = {}
37+
for vv in epoch_logs:
38+
normed[vv] = float(epoch_logs[vv])
39+
self.full_logs.append(normed)
40+
lossfile=os.path.join( self.outputDir, 'full_info.log')
41+
with open(lossfile, 'w') as out:
42+
out.write(json.dumps(self.full_logs))
43+
44+
class newline_callbacks_end(Callback):
45+
def on_epoch_end(self,epoch, epoch_logs={}):
46+
print('\n***callbacks end***\n')
47+
48+
49+
class Losstimer(Callback):
50+
def __init__(self, every = 5):
51+
self.points = []
52+
self.every = every
53+
54+
def on_train_begin(self, logs):
55+
self.start = time()
56+
57+
def on_batch_end(self, batch, logs):
58+
if (batch % self.every) != 0: return
59+
elapsed = time() - self.start
60+
cop = {}
61+
for i, j in logs.items():
62+
cop[i] = float(j)
63+
cop['elapsed'] = elapsed
64+
self.points.append(cop)
65+
66+
class all_callbacks(object):
67+
def __init__(self,
68+
stop_patience=10,
69+
lr_factor=0.5,
70+
lr_patience=1,
71+
lr_epsilon=0.001,
72+
lr_cooldown=4,
73+
lr_minimum=1e-5,
74+
outputDir=''):
75+
76+
77+
78+
self.nl_begin=newline_callbacks_begin(outputDir)
79+
self.nl_end=newline_callbacks_end()
80+
81+
self.stopping = EarlyStopping(monitor='val_loss',
82+
patience=stop_patience,
83+
verbose=1, mode='min')
84+
85+
self.reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=lr_factor, patience=lr_patience,
86+
mode='min', verbose=1, epsilon=lr_epsilon,
87+
cooldown=lr_cooldown, min_lr=lr_minimum)
88+
89+
self.modelbestcheck=ModelCheckpoint(outputDir+"/KERAS_check_best_model.h5",
90+
monitor='val_loss', verbose=1,
91+
save_best_only=True)
92+
93+
self.modelbestcheckweights=ModelCheckpoint(outputDir+"/KERAS_check_best_model_weights.h5",
94+
monitor='val_loss', verbose=1,
95+
save_best_only=True,save_weights_only=True)
96+
97+
self.modelcheckperiod=ModelCheckpoint(outputDir+"/KERAS_check_model_epoch{epoch:02d}.h5", verbose=1,period=10)
98+
99+
self.modelcheck=ModelCheckpoint(outputDir+"/KERAS_check_model_last.h5", verbose=1)
100+
101+
self.modelcheckweights=ModelCheckpoint(outputDir+"/KERAS_check_model_last_weights.h5", verbose=1,save_weights_only=True)
102+
103+
self.tb = TensorBoard(log_dir=outputDir+'/logs')
104+
105+
self.history=History()
106+
self.timer = Losstimer()
107+
108+
self.callbacks=[
109+
self.nl_begin,
110+
self.modelbestcheck,self.modelbestcheckweights, self.modelcheck,self.modelcheckweights,self.modelcheckperiod,
111+
self.reduce_lr, self.stopping, self.nl_end, self.tb, self.history,
112+
self.timer
113+
]

images/AE/reconstructed images.png

172 Bytes
55 KB
Binary file not shown.
9.09 KB
Binary file not shown.
-88 Bytes
Binary file not shown.

model_2/KERAS_check_best_model.h5

190 KB
Binary file not shown.
75.2 KB
Binary file not shown.

model_2/KERAS_check_model_epoch10.h5

190 KB
Binary file not shown.

model_2/KERAS_check_model_epoch20.h5

190 KB
Binary file not shown.

model_2/KERAS_check_model_epoch30.h5

190 KB
Binary file not shown.

model_2/KERAS_check_model_last.h5

190 KB
Binary file not shown.
75.2 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_01_26/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_07_37/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_08_23/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_09_26/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_14_45/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_17_12/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_38_14/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_39_51/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_41_45/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_42_31/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

model_2/logs/train/plugins/profile/2021_12_07_10_43_24/VALANTR.kernel_stats.pb

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)