lr=0.001
    hidden0=500
    hidden1=400    
ut.log_p('drop_mlp4da.py|ad:'+advertiser+'|drop:'+str(dropout)+'|b_size:'+str(batch_size)+' | X:'+str(x_dim) + ' | Hidden 0:'+str(hidden0)+ ' | Hidden 1:'+str(hidden1)+ ' | Hidden 2:'+str(hidden2)+
        ' | L_r:'+str(lr)+ ' | activation1:'+ str(acti_type)+
        ' | lambda:'+str(lambda1)
        )
        
# initialise parameters
arr=[]
arr.append(x_dim)
arr.append(hidden0)
arr.append(hidden1)
arr.append(hidden2)

ww0,bb0=ut.init_weight(x_dim,hidden0,'sigmoid')
ww1,bb1=ut.init_weight(hidden0,hidden1,'sigmoid')
ww2,bb2=ut.init_weight(hidden1,hidden2,'sigmoid')

# ww0,bb0,ww1,bb1,ww2,bb2=da.get_da_weights(train_file,arr,ncases=train_size,batch_size=100000)
# pickle.dump( (ww0,bb0,ww1,bb1,ww2,bb2), open( "2997_da_4l_10.p", "wb" ))

# (ww0,bb0,ww1,bb1,ww2,bb2)=pickle.load( open( "2997_da_4l_10.p", "rb" ) )


# ww2,bb2=ut.init_weight(hidden1,hidden2,'sigmoid')
ww3=rng.uniform(-0.05,0.05,hidden2)
ww3=numpy.zeros(hidden2)
#
bb3=0.
ut.log_p('bat size:'+str(batch_size)+'|X:'+str(x_dim) + ' | Hidden 0:'+str(hidden0)+ ' | Hidden 1:'+str(hidden1)+ ' | Hidden 2:'+str(hidden2)+
        ' | L rate:'+str(lr)+ ' | activation1:'+ str(acti_type)+
        ' | lambda:'+str(lambda1)
        )
        
# initialise parameters
arr=[]
arr.append(x_dim)
arr.append(hidden0)
arr.append(hidden1)
arr.append(hidden2)

# ww0,bb0=ut.init_weight(x_dim,hidden0,'sigmoid')
ww0=numpy.asarray(clicks)
bb0=numpy.zeros(hidden0)
ww1,bb1=ut.init_weight(hidden0,hidden1,'sigmoid')
ww2,bb2=ut.init_weight(hidden1,hidden2,'sigmoid')
# ww0,bb0,ww1,bb1,ww2,bb2=da.get_da_weights(train_file,arr,ncases=train_size,batch_size=100000)
# pickle.dump( (ww0,bb0,ww1,bb1,ww2,bb2), open( "2997_da_4l_10.p", "wb" ))

# (ww0,bb0,ww1,bb1,ww2,bb2)=pickle.load( open( "2997_da_4l_10.p", "rb" ) )


# ww2,bb2=ut.init_weight(hidden1,hidden2,'sigmoid')
ww3=rng.uniform(-0.05,0.05,hidden2)
ww3=numpy.zeros(hidden2)
#
bb3=0.


arr=[]
Beispiel #3
0

log_p('drop_mlp4da.py|ad:' + advertiser + '|drop:' + str(dropout) +
      '|b_size:' + str(batch_size) + ' | X:' + str(x_dim) + ' | Hidden 0:' +
      str(hidden0) + ' | Hidden 1:' + str(hidden1) + ' | Hidden 2:' +
      str(hidden2) + ' | L_r:' + str(lr) + ' | activation1:' + str(acti_type) +
      ' | lambda:' + str(lambda1))

# initialise parameters
arr = []
arr.append(x_dim)
arr.append(hidden0)
arr.append(hidden1)
arr.append(hidden2)

ww0, bb0 = ut.init_weight(x_dim, hidden0, 'sigmoid')
ww1, bb1 = ut.init_weight(hidden0, hidden1, 'sigmoid')
ww2, bb2 = ut.init_weight(hidden1, hidden2, 'sigmoid')

wfile = "rbm_" + str(advertiser) + "_.p"
if os.path.isfile(wfile):
    (ww0, bb0, ww1, bb1, ww2, bb2) = pickle.load(open(wfile, "rb"))
else:
    ww0, bb0, ww1, bb1, ww2, bb2 = gbrbm.get_rbm_weights(
        train_file,
        arr,
        ncases=train_size,
        batch_size=100000,
        fm_model_file=fm_model_file)
    pickle.dump((ww0, bb0, ww1, bb1, ww2, bb2), open(wfile, "wb"))
    return 1 + feat_field[feat] * k + l

def feats_to_layer_one_array(feats):
    x = numpy.zeros(xdim)
    x[0] = w_0
    for feat in feats:
        x[feat_layer_one_index(feat, 0):feat_layer_one_index(feat, k)] = feat_weights[feat]
    return x

ut.log_p('X:'+str(xdim) + ' | Hidden 1:'+str(hidden1)+ ' | Hidden 2:'+str(hidden2)+
        ' | L rate:'+str(lr)+ ' | activation1:'+ str(acti_type)+
        ' | lambda:'+str(lambda1)
        )
        
# initialise parameters
ww1,bb1=ut.init_weight(xdim,hidden1,acti_type)
ww2,bb2=ut.init_weight(hidden1,hidden2,acti_type)
ww3,bb3=ut.init_weight(hidden2,hidden3,acti_type)
ww4,bb4=ut.init_weight(hidden3,hidden4,acti_type)
ww5=numpy.zeros(hidden2)
bb5=0.

# Declare Theano symbolic variables
x = T.matrix("x")
y = T.vector("y")
w1 = theano.shared(ww1, name="w1")
w2 = theano.shared(ww2, name="w2")
w3 = theano.shared(ww3, name="w3")
w4 = theano.shared(ww4, name="w4")
w5 = theano.shared(ww5, name="w5")
b1 = theano.shared(bb1, name="b1")
Beispiel #5
0
    + " | L_r:"
    + str(lr)
    + " | activation1:"
    + str(acti_type)
    + " | lambda:"
    + str(lambda1)
)

# initialise parameters
arr = []
arr.append(x_dim)
arr.append(hidden0)
arr.append(hidden1)
arr.append(hidden2)

ww0, bb0 = ut.init_weight(x_dim, hidden0, "sigmoid")
ww1, bb1 = ut.init_weight(hidden0, hidden1, "sigmoid")
ww2, bb2 = ut.init_weight(hidden1, hidden2, "sigmoid")

wfile = "rbm_" + str(advertiser) + "_.p"
if os.path.isfile(wfile):
    (ww0, bb0, ww1, bb1, ww2, bb2) = pickle.load(open(wfile, "rb"))
else:
    ww0, bb0, ww1, bb1, ww2, bb2 = gbrbm.get_rbm_weights(
        train_file, arr, ncases=train_size, batch_size=100000, fm_model_file=fm_model_file
    )
    pickle.dump((ww0, bb0, ww1, bb1, ww2, bb2), open(wfile, "wb"))


# ww2,bb2=ut.init_weight(hidden1,hidden2,'sigmoid')
ww3 = rng.uniform(-0.05, 0.05, hidden2)