def train(param=PARAMS, sv=SOLVE, small=False):

    sv['name'] = 'TEST'
    input_var = raw_input('Are you testing now? ')
    
    if 'no' in input_var:
        sv.pop('name')
    else:
        sv['name'] += input_var


    #out = u.get(6,small=True, aug=True) 
    imgs, ll = load_rnn_pk(files)
    imgs = imgs.reshape((-1,1,256,256))
    ll   = ll.reshape((-1,1,256,256))
    datas = u.prepare_set(imgs, ll)

    out = u.create_iter(*datas, batch_size=5)
    net = cnn_net(
        use_logis=True
        )

    param['eval_data'] = out[1] 
  
    s = Solver(net, out[0], sv, **param)
    s.train()
    s.predict()
    s.all_to_png()
    s.save_best_model()
    s.plot_process()
Esempio n. 2
0
def main(argv):
    parser = argparse.ArgumentParser()

    # Optional arguments.
    parser.add_argument(
        "--epochs",
        default=200,
        help="The number of train iterations",
    )
    parser.add_argument(
        "--batch_size_train",
        default=100,
        help="number of train samples per batch",
    )
    parser.add_argument(
        "--batch_size_val",
        default=40,
        help="number of validation samples per batch",
    )
    parser.add_argument(
        "--images_dim",
        default=64,
        help="'height, width' dimensions of input images.",
    )
    args = parser.parse_args()

    model = cnn_net(args.images_dim)
    print("Plotting the model")
    plot(model, to_file='model.png')
    train(model, args.epochs, args.batch_size_train, args.batch_size_val, args.images_dim)
def main():
    net = cnn_net()
    img, ll = u.load_pk('../DATA/PK/o1.pk')

    ival, lval = u.augment_sunny(img[:5], ll[:5])

    val = mx.io.NDArrayIter(ival, label=lval)

    model = mx.model.FeedForward.load(
        *Aug40,
        ctx=u.gpu(1),
        learning_rate=6,
        num_epoch=10,
        optimizer='sgd',
        initializer=mx.initializer.Xavier(rnd_type='gaussian'))

    u.predict_draw(model, val, folder='MoveCheck')
def train(param = PARAMS, sv=SOLVE, small=False):

    sv['name'] = 'TEST'
    input_var = raw_input('Are you testing now? ')
    
    if 'no' in input_var:
        sv.pop('name')
    else:
        sv['name'] += input_var


    out = u.get(6,small=True, aug=True) 
    net = cnn_net(
        use_logis=False
        )

    param['eval_data'] = out['val'] 
  
    s = Solver(net, out['train'], sv, **param)
    s.train()
    s.predict()
def test():
    net   = cnn_net()

    data  = get(5, small = True)
    train = data['train']
    val   = data['val']

    for l in [ 1e-3, 3e-3, 6e-3, 1e-2, 3e-2, 6e-2, 1e-1, 3e-1, 6e-1, 1, 3, 6]:
        logging.info('------------------------------------%f-------------------------------', l)
        c = Callback(name=str(l))
        model = mx.model.FeedForward.create(
		  net,
		  train,
          learning_rate = l,
          ctx = [mx.context.gpu(i) for i in [0,1,2]],
		  eval_data = val,
		  eval_metric = mx.metric.create(c.eval),
		  num_epoch = 40,
          )

        c.all_to_png()

        predict_test(model, val, c.path)
Esempio n. 6
0
import ipt
import mxnet as mx
import matplotlib.pyplot as plt
from cnn_internal import fetch_internal
from cnn import cnn_net
import my_utils as mu
import os

p = '/home/zijia/HeartDeepLearning/CNN/Result/<0Save>/<1-17:12:45>[E40]/[ACC-0.92900 E39]'
e = 39
net = cnn_net()
val = mu.get(2, small=True)['val']

outputs, imgs, lls = fetch_internal(net, val, p, e)

stamp = 'Inspect/' + mu.parse_time() + '/'
os.makedirs(stamp)

mu.save_img(imgs[0, 0], stamp + 'Input')
#for k,v in outputs.items():
#    if len(v.shape)>2:
#        mu.save_img(v[0,0], stamp+k)
import ipt
import mxnet as mx
import matplotlib.pyplot as plt
from cnn_internal import fetch_internal
from cnn import cnn_net
import my_utils as mu
import os

p = '/home/zijia/HeartDeepLearning/CNN/Result/<0Save>/<1-17:12:45>[E40]/[ACC-0.92900 E39]'
e = 39
net = cnn_net()
val = mu.get(2,small=True)['val']

outputs, imgs, lls = fetch_internal(net,val,p,e)


stamp = 'Inspect/'+mu.parse_time()+'/'
os.makedirs(stamp)

mu.save_img(imgs[0,0],stamp+'Input')
#for k,v in outputs.items():
#    if len(v.shape)>2:
#        mu.save_img(v[0,0], stamp+k)