self.get_gp = theano.function([], error_pos, allow_input_downcast=True) self.total_params = [ W, W_in, W_out ] + self.gp_mlp.params + self.gen.params + [b_in, b, b_out] print "Discrminator built" def step(self, u_t, h_tm1, W, W_in, W_out, b_in, b_out): h_t1 = T.nnet.relu(T.dot(u_t, W_in) + b_in, alpha=0.2) h_t = T.nnet.sigmoid(h_t1 + T.dot(h_tm1, W)) y_t = T.nnet.sigmoid(T.dot(h_t, W_out) + b_out) return h_t, y_t if __name__ == '__main__': vr = VR('../data/person01_boxing_d4_uncomp.avi') video_inp = T.dmatrix("video_inp") input = [] for i in range(0, 20): input.append( numpy.asarray(cv2.resize(vr.next_frame(), (80, 60)).flatten())) print numpy.min(input), numpy.max(input) new_matrix = (input - numpy.min(input)) / (numpy.max(input) - numpy.min(input) * 1.0) input = new_matrix.T print input disc = Discriminator(memory=1000, time_step=20, h_size=500, n_hid=1000,
mlp_hid=1000, lr=0.0002, video_size=80 * 60, video_inp=video_inp, srng=srng) count_vid = 0 disc_err = 0 fool_err = 0 patience = 10 benevolent = 2 punishement = 1.0001 threshold = 2.0 flag = 1 for l in range(0, 10000): for f in onlyfiles: vr = VR('../data/' + f) count = vr.count_frame() vr = VR('../data/' + f) for j in range(0, count - time_step - 1): input = [] for i in range(0, time_step): input.append( numpy.asarray( cv2.resize(vr.return_frame(j + 1), (80, 60)).flatten())) new_matrix = (input - numpy.min(input)) / (numpy.max(input) - numpy.min(input) * 1.0) input = new_matrix.T disc_err = disc.get_disc(input) fool_err = disc.get_gp() #print disc.train_out()
time_step = 20 eps=0.0 video_inp = T.matrix("video_inp") srng = RandomStreams(seed=12345) disc = Discriminator(memory=1000,time_step=time_step,h_size=500,n_hid=1000,mlp_hid=1000,lr=0.0002,video_size=80*60,video_inp=video_inp,srng=srng) count_vid = 0 disc_err = 0 fool_err =0 patience = 10 benevolent = 2 punishement = 1.0001 threshold = 2.0 flag = 1 for l in range(0,10000): for f in onlyfiles: vr = VR('../data/'+f) count = vr.count_frame() vr = VR('../data/'+f) for j in range(0,count-time_step-1): input=[] for i in range(0,time_step): input.append(numpy.asarray(cv2.resize(vr.return_frame(j+1),(80,60)).flatten())) new_matrix = (input - numpy.min(input))/(numpy.max(input)-numpy.min(input)*1.0) input = new_matrix.T disc_err = disc.get_disc(input) fool_err = disc.get_gp() #print disc.train_out() if flag ==1 and disc_err <threshold: flag = 0 if flag == 0 and fool_err <threshold: flag = 1
self.get_gp = theano.function([], error_pos,allow_input_downcast=True ) self.total_params = [W,W_in,W_out]+self.gp_mlp.params+self.gen.params+[b_in,b,b_out] print "Discrminator built" def step(self,u_t, h_tm1, W, W_in, W_out,b_in,b_out): h_t1 = T.nnet.relu(T.dot(u_t, W_in)+b_in,alpha=0.2) h_t = T.nnet.sigmoid(h_t1+ T.dot(h_tm1, W)) y_t = T.nnet.sigmoid(T.dot(h_t, W_out)+b_out) return h_t, y_t if __name__=='__main__': vr = VR('../data/person01_boxing_d4_uncomp.avi') video_inp = T.dmatrix("video_inp") input=[] for i in range(0,20): input.append(numpy.asarray(cv2.resize(vr.next_frame(),(80,60)).flatten())) print numpy.min(input),numpy.max(input) new_matrix = (input - numpy.min(input))/(numpy.max(input)-numpy.min(input)*1.0) input = new_matrix.T print input disc = Discriminator(memory=1000,time_step=20,h_size=500,n_hid=1000,mlp_hid=500,lr=0.001,video_size=80*60,video_inp=video_inp) print disc.get_auto(input).shape print disc.train_auto(input) print disc.train_disc(input) print disc.train_gp() for i in range(1,1000):