Beispiel #1
0
#!/usr/bin/python

import sys
import deeplearn

retval = deeplearn.load("result.nn")
if retval != 0:
    print "Unable to load network. Error code " + str(retval)
    sys.quit()

print("0,0"),
if deeplearn.test([0.0,0.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("1,0"),
if deeplearn.test([1.0,0.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("0,1"),
if deeplearn.test([0.0,1.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("1,1"),
if deeplearn.test([1.0,1.0])[0] > 0.5:
    print "1"
Beispiel #2
0
#!/usr/bin/env python3

import sys
import deeplearn

retval = deeplearn.load("result.nn")
if retval != 0:
    print("Unable to load network. Error code " + str(retval))
    sys.quit()

print("zero,zero"),
if deeplearn.test(["zero","zero"])[0] > 0.5:
    print("1")
else:
    print("0")

print("one,zero"),
if deeplearn.test(["one","zero"])[0] > 0.5:
    print("1")
else:
    print("0")

print("zero,one"),
if deeplearn.test(["zero","one"])[0] > 0.5:
    print("1")
else:
    print("0")

print("one,one"),
if deeplearn.test(["one","one"])[0] > 0.5:
    print("1")
Beispiel #3
0
import os.path
import deeplearn
import subprocess

if len(sys.argv) < 2:
    print "Error: Specify an image filename"
    sys.exit(1)

image_filename = sys.argv[1];

if not os.path.isfile(image_filename):
    print "Error: File does not exist"
    sys.exit(2)

retval = deeplearn.load("result.nn")
if retval != 0:
    print "Error: Unable to load trained neural network. Error code " + str(retval)
    sys.exit(3)

p = subprocess.Popen(['./catmuzzle', '-f', image_filename],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE)
out, err = p.communicate()
inputs = [float(i) for i in out.split(",")]

print deeplearn.test(inputs)
#if deeplearn.test(inputs)[0] > 0.5:
#    print "1"
#else:
#    print "0"
Beispiel #4
0
#!/usr/bin/env python2

import deeplearn

# Rather than showing numbers show the species names

species = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]

# Load the neural network

deeplearn.load("result.nn")

# These dimensions are similar to those which exist in the
# data set, but are adjusted slightly so that the network
# has never seen these exact values before

print "Expected: " + species[0]
deeplearn.test([5.44, 3.436, 1.667, 0.214])
print "Returned: " + species[deeplearn.getClass()]

print "\nExpected: " + species[1]
deeplearn.test([6.14, 2.75, 4.04, 1.32])
print "Returned: " + species[deeplearn.getClass()]

print "\nExpected: " + species[2]
deeplearn.test([6.71, 3.14, 5.92, 2.29])
print "Returned: " + species[deeplearn.getClass()]
Beispiel #5
0
#!/usr/bin/python

import deeplearn

# Rather than showing numbers show the species names

species = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]

# Load the neural network

deeplearn.load("result.nn")

# These dimensions are similar to those which exist in the
# data set, but are adjusted slightly so that the network
# has never seen these exact values before

print "Expected: " + species[0]
deeplearn.test([5.44, 3.436, 1.667, 0.214])
print "Returned: " + species[deeplearn.getClass()]

print "\nExpected: " + species[1]
deeplearn.test([6.14, 2.75, 4.04, 1.32])
print "Returned: " + species[deeplearn.getClass()]

print "\nExpected: " + species[2]
deeplearn.test([6.71, 3.14, 5.92, 2.29])
print "Returned: " + species[deeplearn.getClass()]
Beispiel #6
0
#!/usr/bin/python

import sys
import deeplearn

retval = deeplearn.load("result.nn")
if retval != 0:
    print "Unable to load network. Error code " + str(retval)
    sys.quit()

print("zero,zero"),
if deeplearn.test(["zero","zero"])[0] > 0.5:
    print "1"
else:
    print "0"

print("one,zero"),
if deeplearn.test(["one","zero"])[0] > 0.5:
    print "1"
else:
    print "0"

print("zero,one"),
if deeplearn.test(["zero","one"])[0] > 0.5:
    print "1"
else:
    print "0"

print("one,one"),
if deeplearn.test(["one","one"])[0] > 0.5:
    print "1"
Beispiel #7
0
#!/usr/bin/python

import sys
import deeplearn

retval = deeplearn.load("result.nn")
if retval != 0:
    print "Unable to load network. Error code " + str(retval)
    sys.quit()

print("0,0"),
if deeplearn.test([0.0, 0.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("1,0"),
if deeplearn.test([1.0, 0.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("0,1"),
if deeplearn.test([0.0, 1.0])[0] > 0.5:
    print "1"
else:
    print "0"

print("1,1"),
if deeplearn.test([1.0, 1.0])[0] > 0.5:
    print "1"