dim_x = DataParser.dimension_x dim_y_hat = DataParser.dimension_y batch_size = 21 neuron_num = 64 epoch_cycle = 50 learning_rate = 0.01 lr = theano.shared(learning_rate) lr_decay = 1.0 # e.g. matrix 3*2 dot matrix 2*1 = matrix 3*1 # [[1., 3.], [2., 2.], [3.,1.]] dot [[2], [1]] = [[5.], [6.], [7.]] x = T.matrix('input', dtype='float64') # matrix of dim_x * batch_size y_hat = T.matrix('reference', dtype='float64') # matrix of dim_y_hat * batch_size # load saved parameters w1,w2,w3,b1,b2,b3 = DataParser.load_matrix(fname = 'parameter.txt') # if no saved parameters, generate them randomly #w1 = DataParser.load_matrix(neuron_num, dim_x, name='w1') # matrix of neurom_num * dim_x #b1 = DataParser.load_matrix(neuron_num, name='b1') # matrix of neuron_num * 1 #w2 = DataParser.load_matrix(neuron_num, neuron_num, name='w2') # matrix of neuron_num * neuron_num #b2 = DataParser.load_matrix(neuron_num, name = 'b2') # matrix of neuron_num * 1 #w3 = DataParser.load_matrix(dim_y_hat, neuron_num , name = 'w3') # matrix of matrix of dim_y_hat * neuron_num #b3 = DataParser.load_matrix(dim_y_hat, name = 'b3') # matrix of dim_y_hat * 1 z1 = T.dot(w1, x) + b1.dimshuffle(0, 'x') a1 = activation_func(z1, 'sigmoid') z2 = T.dot(w2, a1) + b2.dimshuffle(0, 'x') a2 = activation_func(z2, 'sigmoid') z3 = T.dot(w3, a2) + b3.dimshuffle(0, 'x') y = activation_func(z3, 'sigmoid')
neuron_num = 64 epoch_cycle = 2 learning_rate = 0.1 lr = theano.shared(learning_rate) adagrad_t = theano.shared(0) # e.g. matrix 3*2 dot matrix 2*1 = matrix 3*1 # [[1., 3.], [2., 2.], [3.,1.]] dot [[2], [1]] = [[5.], [6.], [7.]] x = T.matrix('input', dtype='float64') # matrix of dim_x * batch_size y_hat = T.matrix('reference', dtype='float64') # matrix of dim_y_hat * batch_size # load saved parameters #w1,w2,w3,b1,b2,b3 = DataParser.load_matrix(fname = 'parameter.txt') # if no saved parameters, generate them randomly w1 = DataParser.load_matrix(neuron_num, dim_x, name='w1') # matrix of neurom_num * dim_x w1_g = theano.shared(np.zeros((neuron_num, dim_x)), name='w1_g') b1 = DataParser.load_matrix(neuron_num, name='b1') # matrix of neuron_num * 1 b1_g = theano.shared(np.zeros(neuron_num), name = 'b1_g') w2 = DataParser.load_matrix(neuron_num, neuron_num, name='w2') # matrix of neuron_num * neuron_num w2_g = theano.shared(np.zeros((neuron_num, neuron_num)), name='w2_g') b2 = DataParser.load_matrix(neuron_num, name = 'b2') # matrix of neuron_num * 1 b2_g = theano.shared(np.zeros(neuron_num), name = 'b2_g') w3 = DataParser.load_matrix(dim_y_hat, neuron_num , name = 'w3') # matrix of matrix of dim_y_hat * neuron_num w3_g = theano.shared(np.zeros((dim_y_hat, neuron_num)), name='w3_g') b3 = DataParser.load_matrix(dim_y_hat, name = 'b3') # matrix of dim_y_hat * 1 b3_g = theano.shared(np.zeros(dim_y_hat), name = 'b3_g') z1 = T.dot(w1, x) + b1.dimshuffle(0, 'x') a1 = activation_func(z1, 'sigmoid') z2 = T.dot(w2, a1) + b2.dimshuffle(0, 'x')