예제 #1
0
def init_params(options):
    ctxdim = options['featureMaps']
    hdim = options['hdim']
    actionNum = options['actions']
    fdim = options['fdim']

    params = OrderedDict()

    params = Saliency_init(params, ctxdim, prefix="recog", name='saliency')

    # FNN channel
    params = ff_init(params, ctxdim, fdim, prefix="recog", name='fullconn')
    # LSTM channel
    params = LSTM_init(params, ctxdim, hdim, prefix="recog", name='lstm')
    params = ff_init(params, hdim, fdim, prefix="recog", name='fullconn_lstm')

    #output
    params = ff_init(params, fdim, actionNum, prefix="recog", name='output')

    tparams = share_params(params)
    # loading params if need
    loadfrom = options['loadfrom']
    if options['load'] and os.path.exists(loadfrom):
        print "loading model parameters from ", loadfrom
        tparams = load_params(loadfrom, tparams, strict=False)

    return tparams
예제 #2
0
def init_params(options):
    ctxdim=options['featureMaps'];
    hdim=options['hdim'];
    actionNum=options['actions'];
    fdim=options['fdim'];

    # print actionNum;
    params=OrderedDict();

    params=SaliencyLSTM_init(params,ctxdim,prefix="recog",name='saliencyLSTM');

    params=ff_init(params,ctxdim,fdim,prefix="recog",name='channel0');

    params=LSTM_init(params,ctxdim,hdim,prefix="recog",name='lstm');
    params=ff_init(params,hdim,fdim,prefix="recog",name='channel1');

    #output
    params=ff_init(params,fdim,actionNum,prefix="recog",name='output');


    tparams=share_params(params);
    # loading params if need
    loadfrom=options['loadfrom'];
    if options['load'] and os.path.exists(loadfrom):
        print "loading model parameters from ",loadfrom;
        tparams = load_params(loadfrom, tparams,strict=False);

    return tparams
def init_params(options):
    ctxdim = options['featureMaps']
    hdim = options['hdim']
    actionNum = options['actions']
    fdim = options['fdim']

    # print actionNum;
    params = OrderedDict()

    params = SaliencyFgbg_init(params,
                               options['locations'],
                               options['featureMaps'],
                               prefix="recog",
                               name='saliencyFgbg')

    params = ff_init(params, ctxdim, fdim, prefix="recog", name='channel0')

    params = LSTM_init(params, ctxdim, hdim, prefix="recog", name='lstm1')
    params = ff_init(params, hdim, fdim, prefix="recog", name='channel1')

    #output
    params = ff_init(params, fdim, actionNum, prefix="recog", name='output')

    # params['recog/saliencyFgbg_w']=theano.gradient.grad_clip(params['recog/saliencyFgbg_w'],-0.1,0.1);
    tparams = share_params(params)
    # loading params if need
    loadfrom = options['loadfrom']
    if options['load']:
        if os.path.exists(loadfrom):
            print "loading model parameters from ", loadfrom
            tparams = load_params(loadfrom, tparams, strict=False)
        else:
            print "Not exist ", loadfrom

    return tparams
예제 #4
0
def init_params(options):
    feadim = options['featureMaps']
    ctxdim = 512
    hdim = options['hdim']
    actionNum = options['actions']
    fdim = 64

    params = OrderedDict()
    #params=Saliency_init(params,ctxdim,prefix="recog");
    #params=ff_init(params,ctxdim,512,prefix="recog",name='ctx_pre');
    params = Linger_init(params, feadim, ctxdim, prefix='recog', name='linger')
    # FNN channel
    params = ff_init(params, ctxdim, fdim, prefix="recog", name='highway')
    # LSTM
    params = LSTM_init(params, ctxdim, hdim, prefix="recog", name='lstm')

    params = ff_init(params, hdim, fdim, prefix="recog", name='fullconn')
    params = ff_init(params, fdim, actionNum, prefix="recog", name='output')

    tparams = share_params(params)
    # loading params if need
    loadfrom = options['loadfrom']
    if options['load'] and os.path.exists(loadfrom):
        print "loading model parameters from ", loadfrom
        tparams = load_params(loadfrom, tparams, strict=False)

    return tparams
import os
import time

from block.layer import LSTM_init,LSTM_layer,ff_init,ff_build,dropout_layer,Saliency_init,Saliency_Layer
from util import load_params,share_params,unzip,itemlist


def init_params(options):
	ctxdim=options['featureMaps'];
	hdim=options['hdim'];
	actionNum=options['actions'];
	fdim=options['fdim'];

	params=OrderedDict();
    params=Saliency_init(params,ctxdim,prefix="recog");
	params=LSTM_init(params,ctxdim,hdim,prefix="recog",name='lstm');
	params=ff_init(params,hdim,fdim,prefix="recog",name='fullconn');
	params=ff_init(params,fdim,actionNum,prefix="recog",name='output');

	tparams=share_params(params);
    # loading params if need
    loadfrom=options['loadfrom'];
    if options['load'] and os.path.exists(loadfrom):
        print "loading model parameters from ",loadfrom;
        tparams = load_params(loadfrom, tparams,strict=False);

    return tparams


def build_model(options,tparams):
    """Build up the whole computation graph