Beispiel #1
0
    train_x, train_y = cf.transfer2PyArrays(trainSet)

    # run the training part
    for i in range(cf.train_steps):
        if (i % 1000 == 0): print('Training step: ', i)
        sess.run(train, {x: train_x, y: train_y})

    print('End training: ', datetime.now())
    '''
    print('W1: ', sess.run(W1))
    print('b1: ', sess.run(b1))
    '''

    # run the verification part
    # =========================

    # retrieve a test case
    for factor in [
            0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.55
    ]:
        #for factor in [0.45, 1.0, 1.55] :
        testCase = cf.ipss_app.getTestCase(factor)
        test_x, test_y = cf.transfer2PyArrays(testCase)

        # compute model output (network voltage)
        model_y = sess.run(nn_model(x), {x: test_x})
        #printArray(model_y, 'model_y')

        netVoltage = cf.transfer2JavaDblAry(model_y[0], size)
        print('model out mismatch: ', cf.ipss_app.getMismatchInfo(netVoltage))
        sess.run(train, {x: train_x, y: train_y})

    print('End training: ', datetime.now())
    '''
    print('W1: ', sess.run(W1))
    print('b1: ', sess.run(b1))
    '''

    # run the verification part
    # =========================
    testSize = 100
    mismatchSet = np.zeros((testSize, 2))
    # retrieve a test case
    for i in range(testSize):
        #for factor in [0.45, 1.0, 1.55] :
        testCase = cf.ipss_app.getTestCase()
        test_x, test_y = cf.transfer2PyArrays(testCase)
        test_x = np.divide(np.subtract(test_x, aver_x), ran_x)
        # compute model output (network voltage)
        model_y = sess.run(nn_model(x), {x: test_x})
        #printArray(model_y, 'model_y')

        netVoltage = cf.transfer2JavaDblAry(model_y[0] * ran_y + aver_y, size)
        mismatchSet[i] = np.array([
            cf.ipss_app.getMismatch(netVoltage)[0],
            cf.ipss_app.getMismatch(netVoltage)[1]
        ])
    train_m, aver_m, ran_m = cf.normalization(mismatchSet)
    print('model out mismatch(aver): ', aver_m)
    print('model out mismatch(range): ', ran_m)