Esempio n. 1
0
        # print("Val Gened: " + str(time.time()-start_time))

        # print("Validating: " + str(time.time()-start_time))
        batch_error = dev_model(input_batch_x, input_batch_y, input_batch_mask)
        # print("#%i cost: %f" % (index, batch_error))
        batch_costs.append(batch_error)
        # print("Validated: " + str(time.time()-start_time))

    # print "Batch Costs: " + str(batch_costs)
    val_acc = 1 - np.mean(batch_costs)
    if val_acc > first:
        print("!!!!!!!!!!FIRST!!!!!!!!!!")
        third = second
        second = first
        first = val_acc
        classifier.save_model(args.model_out)
    elif val_acc > second:
        print("!!!!!!!!!!SECOND!!!!!!!!!!")
        third = second
        second = val_acc
        classifier.save_model(args.model_out + ".2")
    elif val_acc > third:
        print("!!!!!!!!!!THIRD!!!!!!!!!!")
        third = val_acc
        classifier.save_model(args.model_out + ".3")
    dev_acc.append(val_acc)
    now_time = time.time()
    print("Dev accuracy: " + str(dev_acc[-1]))
    print("Current time: " + str(now_time - start_time))
    classifier.save_model("models/temp.mdl")
        # print("#%i cost: %f" % (index, batch_error))
        for s, e in reversed(pred_mask):
            print "s = %i, e = %i" % (s, e)
            batch_pred = np.delete(batch_pred, [i for i in range(s, e)])
        batch_preds.extend(batch_pred.tolist())
        print len(batch_preds)
        # print("Validated: " + str(time.time()-start_time))

    # print "Batch Costs: " + str(batch_costs)
    val_acc = 100.0 - calculate_PER(batch_preds, val_y)
    if val_acc > first:
        print ("!!!!!!!!!!FIRST!!!!!!!!!!")
        third = second
        second = first
        first = val_acc
        classifier.save_model(args.model_out)
    elif val_acc > second:
        print ("!!!!!!!!!!SECOND!!!!!!!!!!")
        third = second
        second = val_acc
        classifier.save_model(args.model_out + ".2")
    elif val_acc > third:
        print ("!!!!!!!!!!THIRD!!!!!!!!!!")
        third = val_acc
        classifier.save_model(args.model_out + ".3")
    dev_acc.append(val_acc)
    now_time = time.time()
    print ("100 - Phone Error Rate: " + str(dev_acc[-1]))
    print ("Current time: " + str(now_time - start_time))
    classifier.save_model("models/temp.mdl")