def __init__(self, config): self.config = config batch_size = config['batch_size'] num_seq = config['num_seq'] self.n_timesteps = config['num_timesteps'] num_joints = config['num_joints'] classes_num = config['classes_num'] # ##################### BUILD NETWORK ########################## mask = T.fvector('mask') y = T.lvector('y') target = T.ftensor3('target') rand = T.fvector('rand') trng = RandomStreams(1234) use_noise = T.fscalar('use_noise') print '... building the model' self.layers = [] params = [] weight_types = [] conv_fea = T.ftensor4('conv_fea') #(49, 16, 8, 1024) lstm_att_layer15 = JointAttentionLstmLayer(config, num_joints, conv_fea=conv_fea, mask=mask, batch_size=batch_size, num_seq=num_seq, trng=trng, use_noise=use_noise, n_in=1024 * 5, n_out=1024, dim_part=32) self.layers.append(lstm_att_layer15) params += lstm_att_layer15.params weight_types += lstm_att_layer15.weight_type self.conv_fea = conv_fea softmax_input = lstm_att_layer15.output softmax_layer15 = SoftmaxLayer(input=softmax_input, n_in=1024, n_out=21) self.layers.append(softmax_layer15) params += softmax_layer15.params weight_types += softmax_layer15.weight_type # #################### NETWORK BUILT ####################### self.cost_nll = softmax_layer15.negative_log_likelihood(y, mask) self.cost_jhmdb_attention = T.mean(T.sum(T.sum( 0.5 * (lstm_att_layer15.attention - target)**2, axis=1), axis=1), axis=0, dtype=theano.config.floatX) self.cost = self.cost_nll + self.cost_jhmdb_attention self.errors_video = softmax_layer15.errors_video( y, mask, batch_size, num_seq) self.params = params self.prob = softmax_layer15.p_y_given_x self.mask = mask self.y = y self.target = target self.rand = rand self.weight_types = weight_types self.batch_size = batch_size self.num_seq = num_seq self.use_noise = use_noise