Minor changes in CNNCreator.ftl

parent 8f0fa3d0
Pipeline #72957 passed with stages
in 5 minutes
......@@ -6,10 +6,10 @@ import numpy as np
import logging
import os
import shutil
#import h5py
import sys
#class CNNCreator_SimpleNetworkRelu:
#TODO: Check whether class is needed
#class ${tc.fileNameWithoutEnding}:
module = None
_data_dir_ = "data/${tc.fullArchitectureName}/"
......@@ -19,12 +19,19 @@ _input_names_ = [${tc.join(tc.architectureInputs, ",", "'", "'")}]
_input_shapes_ = [<#list tc.architecture.inputs as input>(${tc.join(input.definition.type.dimensions, ",")})</#list>]
_output_names_ = [${tc.join(tc.architectureOutputs, ",", "'", "_label'")}]
INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#TODO: Modify paths to make them dynamic
#For Windows
#INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
#PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0)
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0)#' for GPU processing
#For Ubuntu
INIT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0) #for CPU processing
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0) #for GPU processing
#data and label are dummy at the moment
# randomly creates 30x30 patches of ones or zeros with label 1 and 0 respectively
def get_dummy_data(batchsize) :
data = []
......@@ -48,14 +55,12 @@ def AddInput(model, batch_size):
return data, label
#def create_model(model, data, device_opts): #data argument is dummy at the moment
def create_model(model, device_opts):
with core.DeviceScope(device_opts):
${tc.include(tc.architecture.body)}
# add loss and optimizer
#def add_training_operators(model, output, label, device_opts) : #label argument is dummy at the moment
# this adds the loss and optimizer
def add_training_operators(model, output, device_opts) :
with core.DeviceScope(device_opts):
......@@ -69,9 +74,6 @@ def add_training_operators(model, output, device_opts) :
def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
train_model= model_helper.ModelHelper(name="train_net")
#data, label = AddInput(train_model, batch_size=100)
#predictions = create_model(train_model, data, device_opts=device_opts)
#add_training_operators(train_model, predictions, label, device_opts=device_opts)
${tc.join(tc.architectureOutputs, ",", "","")} = create_model(train_model, device_opts=device_opts)
add_training_operators(train_model, ${tc.join(tc.architectureOutputs, ",", "","")}, device_opts=device_opts)
with core.DeviceScope(device_opts):
......@@ -91,7 +93,6 @@ def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
print '\nrunning test model'
test_model= model_helper.ModelHelper(name="test_net", init_params=False)
#create_model(test_model, data, device_opts=device_opts)
create_model(test_model, device_opts=device_opts)
workspace.RunNetOnce(test_model.param_init_net)
workspace.CreateNet(test_model.net, overwrite=True)
......
......@@ -6,10 +6,10 @@ import numpy as np
import logging
import os
import shutil
#import h5py
import sys
#class CNNCreator_SimpleNetworkRelu:
#TODO: Check whether class is needed
#class CNNCreator_Alexnet:
module = None
_data_dir_ = "data/Alexnet/"
......@@ -19,12 +19,19 @@ _input_names_ = ['data']
_input_shapes_ = [(3,224,224)]
_output_names_ = ['predictions_label']
INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#TODO: Modify paths to make them dynamic
#For Windows
#INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
#PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0)
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0)#' for GPU processing
#For Ubuntu
INIT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0) #for CPU processing
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0) #for GPU processing
#data and label are dummy at the moment
# randomly creates 30x30 patches of ones or zeros with label 1 and 0 respectively
def get_dummy_data(batchsize) :
data = []
......@@ -48,7 +55,6 @@ def AddInput(model, batch_size):
return data, label
#def create_model(model, data, device_opts): #data argument is dummy at the moment
def create_model(model, device_opts):
with core.DeviceScope(device_opts):
......@@ -150,8 +156,7 @@ def create_model(model, device_opts):
model.net.AddExternalOutput(predictions)
return predictions
# add loss and optimizer
#def add_training_operators(model, output, label, device_opts) : #label argument is dummy at the moment
# this adds the loss and optimizer
def add_training_operators(model, output, device_opts) :
with core.DeviceScope(device_opts):
......@@ -165,9 +170,6 @@ def add_training_operators(model, output, device_opts) :
def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
train_model= model_helper.ModelHelper(name="train_net")
#data, label = AddInput(train_model, batch_size=100)
#predictions = create_model(train_model, data, device_opts=device_opts)
#add_training_operators(train_model, predictions, label, device_opts=device_opts)
predictions = create_model(train_model, device_opts=device_opts)
add_training_operators(train_model, predictions, device_opts=device_opts)
with core.DeviceScope(device_opts):
......@@ -187,7 +189,6 @@ def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
print '\nrunning test model'
test_model= model_helper.ModelHelper(name="test_net", init_params=False)
#create_model(test_model, data, device_opts=device_opts)
create_model(test_model, device_opts=device_opts)
workspace.RunNetOnce(test_model.param_init_net)
workspace.CreateNet(test_model.net, overwrite=True)
......
......@@ -6,10 +6,10 @@ import numpy as np
import logging
import os
import shutil
#import h5py
import sys
#class CNNCreator_SimpleNetworkRelu:
#TODO: Check whether class is needed
#class CNNCreator_CifarClassifierNetwork:
module = None
_data_dir_ = "data/CifarClassifierNetwork/"
......@@ -19,12 +19,19 @@ _input_names_ = ['data']
_input_shapes_ = [(3,32,32)]
_output_names_ = ['softmax_label']
INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#TODO: Modify paths to make them dynamic
#For Windows
#INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
#PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0)
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0)#' for GPU processing
#For Ubuntu
INIT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0) #for CPU processing
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0) #for GPU processing
#data and label are dummy at the moment
# randomly creates 30x30 patches of ones or zeros with label 1 and 0 respectively
def get_dummy_data(batchsize) :
data = []
......@@ -48,7 +55,6 @@ def AddInput(model, batch_size):
return data, label
#def create_model(model, data, device_opts): #data argument is dummy at the moment
def create_model(model, device_opts):
with core.DeviceScope(device_opts):
......@@ -236,8 +242,7 @@ def create_model(model, device_opts):
model.net.AddExternalOutput(softmax)
return softmax
# add loss and optimizer
#def add_training_operators(model, output, label, device_opts) : #label argument is dummy at the moment
# this adds the loss and optimizer
def add_training_operators(model, output, device_opts) :
with core.DeviceScope(device_opts):
......@@ -251,9 +256,6 @@ def add_training_operators(model, output, device_opts) :
def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
train_model= model_helper.ModelHelper(name="train_net")
#data, label = AddInput(train_model, batch_size=100)
#predictions = create_model(train_model, data, device_opts=device_opts)
#add_training_operators(train_model, predictions, label, device_opts=device_opts)
softmax = create_model(train_model, device_opts=device_opts)
add_training_operators(train_model, softmax, device_opts=device_opts)
with core.DeviceScope(device_opts):
......@@ -273,7 +275,6 @@ def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
print '\nrunning test model'
test_model= model_helper.ModelHelper(name="test_net", init_params=False)
#create_model(test_model, data, device_opts=device_opts)
create_model(test_model, device_opts=device_opts)
workspace.RunNetOnce(test_model.param_init_net)
workspace.CreateNet(test_model.net, overwrite=True)
......
......@@ -6,10 +6,10 @@ import numpy as np
import logging
import os
import shutil
#import h5py
import sys
#class CNNCreator_SimpleNetworkRelu:
#TODO: Check whether class is needed
#class CNNCreator_VGG16:
module = None
_data_dir_ = "data/VGG16/"
......@@ -19,12 +19,19 @@ _input_names_ = ['data']
_input_shapes_ = [(3,224,224)]
_output_names_ = ['predictions_label']
INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#TODO: Modify paths to make them dynamic
#For Windows
#INIT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
#PREDICT_NET = 'D:/Yeverino/git_projects/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0)
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0)#' for GPU processing
#For Ubuntu
INIT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/init_net'
PREDICT_NET = '/home/carlos/Documents/git/Caffe2_scripts/caffe2_ema_cnncreator/predict_net'
#device_opts = core.DeviceOption(caffe2_pb2.CPU, 0) #for CPU processing
device_opts = core.DeviceOption(caffe2_pb2.CUDA, 0) #for GPU processing
#data and label are dummy at the moment
# randomly creates 30x30 patches of ones or zeros with label 1 and 0 respectively
def get_dummy_data(batchsize) :
data = []
......@@ -48,7 +55,6 @@ def AddInput(model, batch_size):
return data, label
#def create_model(model, data, device_opts): #data argument is dummy at the moment
def create_model(model, device_opts):
with core.DeviceScope(device_opts):
......@@ -125,8 +131,7 @@ def create_model(model, device_opts):
model.net.AddExternalOutput(predictions)
return predictions
# add loss and optimizer
#def add_training_operators(model, output, label, device_opts) : #label argument is dummy at the moment
# this adds the loss and optimizer
def add_training_operators(model, output, device_opts) :
with core.DeviceScope(device_opts):
......@@ -140,9 +145,6 @@ def add_training_operators(model, output, device_opts) :
def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
train_model= model_helper.ModelHelper(name="train_net")
#data, label = AddInput(train_model, batch_size=100)
#predictions = create_model(train_model, data, device_opts=device_opts)
#add_training_operators(train_model, predictions, label, device_opts=device_opts)
predictions = create_model(train_model, device_opts=device_opts)
add_training_operators(train_model, predictions, device_opts=device_opts)
with core.DeviceScope(device_opts):
......@@ -162,7 +164,6 @@ def train(INIT_NET, PREDICT_NET, epochs, batch_size, device_opts) :
print '\nrunning test model'
test_model= model_helper.ModelHelper(name="test_net", init_params=False)
#create_model(test_model, data, device_opts=device_opts)
create_model(test_model, device_opts=device_opts)
workspace.RunNetOnce(test_model.param_init_net)
workspace.CreateNet(test_model.net, overwrite=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment