5e173b9c35b4114026c04f024e9deb8bfb8628eb,examples/simple_but_ugly/models.py,,,#,141

Before Change




// Create a template pipeline
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")
)

// Create another template
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")
        //.init_model("MyModel")
        .load(data)
        //.train_global()
        .train_static()
        //.train_dynamic()
        .train_in_batch("dynamic_model")
        //.train_model("MyModel")
        .train_model("my_model")
        .train_model("my_model2", save_to=V("output"))
        .run(K//10, n_epochs=1, shuffle=False, drop_last=False, lazy=True)
)

// Create another template
t = time()
//res = (pp2 << ds_data).run()
print(time() - t)

print("-------------------------------------------")
print("============== start run ==================")
t = time()
res = (pp2 << ds_data).run()
print(time() - t)
//ModelDirectory.print()


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)

//ModelDirectory.print()

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")
           //.test_dynamic()
)

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




// Create a template pipeline
template_pp = (Pipeline(config=config)
                .init_variable("loss history", init=list, init_on_each_run=True)
                .init_model("static_model", MyModel)
)

// Create another template
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//10, n_epochs=1, shuffle=False, drop_last=False, lazy=True)
)

// Create another template
t = time()
//res = (pp2 << ds_data).run()
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)
Italian Trulli
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: