5e173b9c35b4114026c04f024e9deb8bfb8628eb,examples/simple_but_ugly/models.py,,,#,141
Before Change
template_pp = (Pipeline(config=config)
.init_variable("session", init=tf.Session)
.init_variable("loss history", init=list, init_on_each_run=True)
.init_model("static_model")
)
pp2 = (template_pp
.init_variable("session", sess)
.init_variable("print lock", init=threading.Lock)
.init_model("dynamic", MyModel, "my_model", config=F(MyBatch.make_data_for_dynamic))
.init_model("dynamic", MyModel, "my_model2")
.load(data)
.train_static()
.train_in_batch("dynamic_model")
.train_model("my_model")
.train_model("my_model2", save_to=V("output"))
.run(K
)
t = time()
print(time() - t)
print("-------------------------------------------")
print("============== start run ==================")
t = time()
res = (pp2 << ds_data).run()
print(time() - t)
print("-------------------------------------------------")
print("============== start gen_batch ==================")
res = pp2 << ds_data
print("Start iterating...")
t = time()
t1 = t
for batch in res.gen_batch(K, n_epochs=1, drop_last=True, prefetch=Q*0):
with res.get_variable("print lock"):
print("Batch", batch.indices, "is ready in", time() - t1)
t1 = time()
print("Stop iterating:", time() - t)
print("loss:", res.get_variable("loss history"))
print("global:", res.get_model_by_name("global_model"))
print("dynamic:", res.get_model_by_name("dynamic_model"))
pp3 = (Pipeline()
.init_variable("session", sess)
.import_model("my_model2", res)
.load(data)
.train_model("my_model2")
)
print("--------------------------------------------")
print("============== start test ==================")
res2 = pp3 << ds_data
for batch in res2.gen_batch(3, n_epochs=1, drop_last=True, prefetch=Q*0):
with res.get_variable("print lock"):
print("Batch", batch.indices, "is ready in", time() - t1)
t1 = time()
res3 = pp3 << ds_data
print("predict")
res3.run(3, n_epochs=1)
After Change
template_pp = (Pipeline(config=config)
.init_variable("loss history", init=list, init_on_each_run=True)
.init_model("static_model", MyModel)
)
pp2 = (template_pp
.init_variable("print lock", init=threading.Lock)
.init_model("dynamic", MyModel, "my_model", config=F(MyBatch.make_data_for_dynamic))
.init_model("dynamic", MyModel, "my_model2")
.load(data)
.train_model("my_model")
.train_model("my_model2", save_to=V("output"))
.run(K
)
t = time()
print(time() - t)
print("-------------------------------------------")
print("============== start run ==================")
t = time()
res = (pp2 << ds_data).run()
print(time() - t)
print("-------------------------------------------------")
print("============== start gen_batch ==================")
res = pp2 << ds_data
print("Start iterating...")
t = time()
t1 = t
for batch in res.gen_batch(K, n_epochs=1, drop_last=True, prefetch=Q*0):
with res.get_variable("print lock"):
print("Batch", batch.indices, "is ready in", time() - t1)
t1 = time()
print("Stop iterating:", time() - t)
pp3 = (Pipeline()
.import_model("my_model2", res)
.load(data)
.train_model("my_model2")
)
print("--------------------------------------------")
print("============== start test ==================")
res2 = pp3 << ds_data
for batch in res2.gen_batch(3, n_epochs=1, drop_last=True, prefetch=Q*0):
with res.get_variable("print lock"):
print("Batch", batch.indices, "is ready in", time() - t1)
t1 = time()
res3 = pp3 << ds_data
print("predict")
res3.run(3, n_epochs=1)

In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 11
Instances
Project Name: analysiscenter/batchflow
Commit Name: 5e173b9c35b4114026c04f024e9deb8bfb8628eb
Time: 2018-01-14
Author: rhudor@gmail.com
File Name: examples/simple_but_ugly/models.py
Class Name:
Method Name:
Project Name: analysiscenter/batchflow
Commit Name: 00f3cccf83006b54461f417419ac200560e7d70d
Time: 2017-12-10
Author: rhudor@gmail.com
File Name: examples/opensets/mnist_model2.py
Class Name:
Method Name:
Project Name: analysiscenter/batchflow
Commit Name: 2fb926993d13f7702b31d82f3d29868514f45efc
Time: 2017-11-04
Author: rhudor@gmail.com
File Name: examples/opensets/mnist_model2.py
Class Name:
Method Name: