예제 #1
0
파일: Exp.py 프로젝트: yyht/deepC
 def test_Exp1D_double(self):
     npr = np.exp(self.np_double_a)
     dcr = dc.exp(self.dc_double_a)
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.float64),
                                rtol=1e-3,
                                atol=1e-3)
예제 #2
0
파일: Exp.py 프로젝트: yyht/deepC
 def test_Exp2D_double_2(self):
     np_double_a = np.reshape(self.np_double_a, (6, 8))
     dc_double_a = dc.reshape(self.dc_double_a, (6, 8))
     npr = np.exp(np_double_a)
     dcr = dc.exp(dc_double_a)
     np.testing.assert_allclose(npr.flatten(),
                                np.array(dcr.data()).astype(np.float64),
                                rtol=1e-3,
                                atol=1e-3)
예제 #3
0
파일: Exp.py 프로젝트: yyht/deepC
 def test_Exp2D_float_3(self):
     np_float_a = np.reshape(self.np_float_a, (12, 4))
     dc_float_a = dc.reshape(self.dc_float_a, (12, 4))
     npr = np.exp(np_float_a)
     dcr = dc.exp(dc_float_a)
     np.testing.assert_allclose(npr.flatten(),
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)
예제 #4
0
파일: demo.mnist.py 프로젝트: yyht/deepC
    result = run(command,
                 stdout=PIPE,
                 stderr=PIPE,
                 universal_newlines=True,
                 shell=True)
    for line in result.stdout.split("\n"):
        if (line.find("writing file ") == 0):
            resultFile = line[13:line.find('.', -1)].split()[0]
            with open(resultFile, 'r') as f:
                return f.read()
    return ""


# Run model in the loop
import deepC.dnnc as dc
for i in range(5):
    index = random.randint(0, len(images) - 1)
    write_image(index)

    model_result = run_model("./mnist.exe ./image.data").strip("[]")

    # Convert log softmax output to probability
    log_probs = dc.array([float(f) for f in model_result.strip("[]").split()])
    probabilities = dc.exp(log_probs)

    trueLabel = labels[index]
    prediction = dc.argmax(probabilities)[0]
    display(images[index])
    print("True label = ", labels[index])
    print("Model Prediction: ", dc.argmax(probabilities))