L2,
                          L1_fm,
                          L2_fm,
                          D,
                          alpha,
                          beta,
                          alpha_fm=alpha_fm,
                          beta_fm=beta_fm,
                          dropoutRate=dropoutRate)

print("Start Training:")
for e in range(n_epochs):

    # if it is the first epoch, then don't use L1_fm or L2_fm
    if e == 0:
        learner.L1_fm = 0.
        learner.L2_fm = 0.
    else:
        learner.L1_fm = L1_fm
        learner.L2_fm = L2_fm

    cvLoss = 0.
    cvCount = 0.
    progressiveLoss = 0.
    progressiveCount = 0.
    for t, date, ID, x, y in data(trainingFile, D, hashSalt):
        if date == 30:
            p = learner.predictWithDroppedOutModel(x)
            loss = logLoss(p, y)
            cvLoss += loss
            cvCount += 1.
Esempio n. 2
0
n_epochs = 5


####
start = datetime.now()

# initialize a FM learner
learner = FM_FTRL_machine(fm_dim, fm_initDev, L1, L2, L1_fm, L2_fm, D, alpha, beta, alpha_fm = alpha_fm, beta_fm = beta_fm)

print("Start Training:")
for e in range(n_epochs):
    
    # if it is the first epoch, then don't use L1_fm or L2_fm
    if e == 0:
        learner.L1_fm = 0.
        learner.L2_fm = 0.
    else:
        learner.L1_fm = L1_fm
        learner.L2_fm = L2_fm
    
    cvLoss = 0.
    cvCount = 0.
    progressiveLoss = 0.
    progressiveCount = 0.
    for t, date, ID, x, y in data(trainingFile, D, hashSalt):
        if date == 30:
            p = learner.predict(x)
            loss = logLoss(p, y)
            cvLoss += loss
            cvCount += 1.
D = 2 ** 20

L1, L2 = 1.0, .1
L1_fm, L2_fm = 1.0, .1

n_epochs = 1

start = datetime.now()

learner = FM_FTRL_machine(fm_dim, fm_initDev, L1, L2, L1_fm, L2_fm, D, alpha, beta, alpha_fm = alpha_fm, beta_fm = beta_fm)

print("Start Training:")

for e in range(n_epochs):
    learner.L1_fm = 0 if e == 0 else L1_fm
    learner.L2_fm = 0 if e == 0 else L2_fm
    
    progressiveLoss, progressiveCount = 0., 0.

    for t, x, y in data(trainingFile, D):
        p = learner.predict(x)
        loss = logLoss(p, y)
        learner.update(x, p, y)
            
        progressiveLoss += loss
        progressiveCount += 1.
        if t % reportFrequency == 0:                
            print("Epoch %d\tcount: %d\tProgressive Loss: %f" % (e, t, progressiveLoss / progressiveCount))
        
with open('submission.csv', 'w') as output:
Esempio n. 4
0
learner = FM_FTRL_machine(fm_dim,
                          fm_initDev,
                          L1,
                          L2,
                          L1_fm,
                          L2_fm,
                          D,
                          alpha,
                          beta,
                          alpha_fm=alpha_fm,
                          beta_fm=beta_fm)

print("Start Training:")

for e in range(n_epochs):
    learner.L1_fm = 0 if e == 0 else L1_fm
    learner.L2_fm = 0 if e == 0 else L2_fm

    progressiveLoss, progressiveCount = 0., 0.

    for t, x, y in data(trainingFile, D):
        p = learner.predict(x)
        loss = logLoss(p, y)
        learner.update(x, p, y)

        progressiveLoss += loss
        progressiveCount += 1.
        if t % reportFrequency == 0:
            print("Epoch %d\tcount: %d\tProgressive Loss: %f" %
                  (e, t, progressiveLoss / progressiveCount))