Commit a3199d5d authored by Margret A. Riegert's avatar Margret A. Riegert
Browse files

2to3 on all python scripts


Former-commit-id: 3d0c28dea9c1d87d31142c76d49504b6043a95a2 [formerly 718a88b42160f1af06b6beb22ea2838915bec8eb]
Former-commit-id: a171280e102c8e1ccdf5cea7eb95bcf784fc4950
parent 9d3d4969
......@@ -15,7 +15,7 @@ class bcolors:
UNDERLINE = '\033[4m'
def printUsage():
print "Usage: python qos.py <original file> <nn file>"
print("Usage: python qos.py <original file> <nn file>")
exit(1)
pass;
......@@ -56,4 +56,4 @@ for i in range(len(origLines)):
absError += e
pass;
print bcolors.FAIL + "*** Error: %1.8f" % (absError/float(len(origLines))) + bcolors.ENDC
print(bcolors.FAIL + "*** Error: %1.8f" % (absError/float(len(origLines))) + bcolors.ENDC)
......@@ -15,7 +15,7 @@ class bcolors:
UNDERLINE = '\033[4m'
def printUsage():
print "Usage: python qos.py <original file> <nn file>"
print("Usage: python qos.py <original file> <nn file>")
exit(1)
pass;
......@@ -63,4 +63,4 @@ for i in range(len(origLines)):
absError += e
pass;
print bcolors.FAIL + "*** Error: %1.8f" % (absError/float(len(origLines))) + bcolors.ENDC
print(bcolors.FAIL + "*** Error: %1.8f" % (absError/float(len(origLines))) + bcolors.ENDC)
......@@ -15,7 +15,7 @@ class bcolors:
UNDERLINE = '\033[4m'
def printUsage():
print "Usage: python qos.py <original file> <nn file>"
print("Usage: python qos.py <original file> <nn file>")
exit(1)
pass;
......@@ -63,4 +63,4 @@ for i in range(len(origLines)):
absError += e
pass;
print bcolors.FAIL + "*** Error: %1.8f" % (absError/len(origLines)) + bcolors.ENDC
print(bcolors.FAIL + "*** Error: %1.8f" % (absError/len(origLines)) + bcolors.ENDC)
......@@ -15,7 +15,7 @@ class bcolors:
UNDERLINE = '\033[4m'
def printUsage():
print "Usage: python qos.py <original file> <nn file>"
print("Usage: python qos.py <original file> <nn file>")
exit(1)
pass;
......@@ -45,4 +45,4 @@ for i in range(len(origLines)):
pass;
print bcolors.FAIL + "*** Error: %1.8f" % (missPred/float(len(origLines))) + bcolors.ENDC
print(bcolors.FAIL + "*** Error: %1.8f" % (missPred/float(len(origLines))) + bcolors.ENDC)
......@@ -24,7 +24,7 @@ class JsonCloak(object):
try: inFile = open(filePath)
except:
inFile = None
print('Error! Oops! Cannot open ' + str(filePath) + '!')
print(('Error! Oops! Cannot open ' + str(filePath) + '!'))
return
pass
......@@ -36,7 +36,7 @@ class JsonCloak(object):
try: outFile = open(filePath, 'w')
except:
outFile = None
print('Error! Oops! Cannot open ' + filePath + '!')
print(('Error! Oops! Cannot open ' + filePath + '!'))
return
pass
......
......@@ -4,8 +4,8 @@ Created on Jul 26, 2012
@author: hadianeh
'''
from JsonCloak.JsonCloak import JsonCloak
from NeuralParrot.NeuralNet import NeuralNet
from .JsonCloak.JsonCloak import JsonCloak
from .NeuralParrot.NeuralNet import NeuralNet
import re
class FannNet(object):
......@@ -19,7 +19,7 @@ class FannNet(object):
try:
f = open(path)
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -89,7 +89,7 @@ class FannNet(object):
for l in self.nn.neurons:
for n in l:
for j in range(len(n.w)):
print synapses[i]
print(synapses[i])
n.w[j] = synapses[i][1]
i += 1
pass
......@@ -105,7 +105,7 @@ class FannNet(object):
def saveEssence(self, path):
try: f = open(path, 'w')
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -168,19 +168,19 @@ if __name__ == '__main__':
exit()
x = [-1, -1]
y = fannNet.nn.compute(x)
print x, y
print(x, y)
x = [-1, 1]
y = fannNet.nn.compute(x)
print x, y
print(x, y)
x = [1, -1]
y = fannNet.nn.compute(x)
print x, y
print(x, y)
x = [1, 1]
y = fannNet.nn.compute(x)
print x, y
print(x, y)
exit(0)
pass
......
......@@ -24,7 +24,7 @@ class JsonCloak(object):
try: inFile = open(filePath)
except:
inFile = None
print('Error! Oops! Cannot open ' + str(filePath) + '!')
print(('Error! Oops! Cannot open ' + str(filePath) + '!'))
return
pass
......@@ -36,7 +36,7 @@ class JsonCloak(object):
try: outFile = open(filePath, 'w')
except:
outFile = None
print('Error! Oops! Cannot open ' + filePath + '!')
print(('Error! Oops! Cannot open ' + filePath + '!'))
return
pass
......
......@@ -65,8 +65,8 @@ f = {
}
if __name__ == '__main__':
print f['sigmoid'][0](-100, 10)
print f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10)
print(f['sigmoid'][0](-100, 10))
print(f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10))
exit(0)
pass
......
......@@ -4,7 +4,7 @@ Created on Mar 3, 2012
@author: hadianeh
'''
from Neuron import Neuron
from .Neuron import Neuron
import json
class NeuralNet(object):
......@@ -77,7 +77,7 @@ class NeuralNet(object):
def load(self, path):
try: f = open(path)
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -88,7 +88,7 @@ class NeuralNet(object):
def save(self, path):
try: f = open(path, 'w')
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -167,15 +167,15 @@ class NeuralNet(object):
def dump(self):
for i, n in enumerate(self.hiddenLayer):
print i, 'h'*64
print n.w
print(i, 'h'*64)
print(n.w)
pass
for i, n in enumerate(self.outputLayer):
print i, 'o'*64
print n.w
print(i, 'o'*64)
print(n.w)
pass
print 'o'*64
print('o'*64)
pass
pass
......@@ -212,14 +212,14 @@ if __name__ == '__main__':
# nn.train((x, y, d), eta, epsilon, nEpoch)
print '-'*64
print nn
print '-'*64
print('-'*64)
print(nn)
print('-'*64)
for i in range(len(x)):
o = nn.compute(x[i])
print 'x[i]:', x[i]
print 'y[i]:', y[i], 'o:', o
print('x[i]:', x[i])
print('y[i]:', y[i], 'o:', o)
pass
# print 'rmse', nn.test((x, y))
......@@ -257,23 +257,23 @@ if __name__ == '__main__':
for i in range(len(x)):
o = nn.compute(x[i])
print x[i]
print y[i], o
print(x[i])
print(y[i], o)
print '&'*64
print('&'*64)
s = nn
print s
print(s)
print '&'*64
print('&'*64)
nn.fromStr(s)
print nn
print(nn)
nn.dump()
for i in range(len(x)):
o = nn.compute(x[i])
print x[i]
print y[i], o
print(x[i])
print(y[i], o)
pass
......
......@@ -5,7 +5,7 @@ Created on Mar 4, 2012
'''
from random import random
from Activation import f
from .Activation import f
import json
class Neuron(object):
......@@ -119,22 +119,22 @@ if __name__ == '__main__':
n.backProp(eta, 1)
pass
print k, err
print(k, err)
pass
print n
print(n)
for i in range(len(x)):
print x[i], y[i], n.compute(x[i])
print(x[i], y[i], n.compute(x[i]))
print '^'*64
print('^'*64)
s = str(n)
print s
print(s)
n.__init__(0)
n.fromStr(s)
for i in range(len(x)):
print x[i], y[i], n.compute(x[i])
print(x[i], y[i], n.compute(x[i]))
exit(0)
pass
......@@ -65,8 +65,8 @@ f = {
}
if __name__ == '__main__':
print f['sigmoid'][0](-100, 10)
print f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10)
print(f['sigmoid'][0](-100, 10))
print(f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10))
exit(0)
pass
......
......@@ -4,7 +4,7 @@ Created on Mar 3, 2012
@author: hadianeh
'''
from Neuron import Neuron
from .Neuron import Neuron
import json
class NeuralNet(object):
......@@ -77,7 +77,7 @@ class NeuralNet(object):
def load(self, path):
try: f = open(path)
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -88,7 +88,7 @@ class NeuralNet(object):
def save(self, path):
try: f = open(path, 'w')
except:
print 'Error: Oops! Cannot open ' + path +'!'
print('Error: Oops! Cannot open ' + path +'!')
return False
pass
......@@ -167,15 +167,15 @@ class NeuralNet(object):
def dump(self):
for i, n in enumerate(self.hiddenLayer):
print i, 'h'*64
print n.w
print(i, 'h'*64)
print(n.w)
pass
for i, n in enumerate(self.outputLayer):
print i, 'o'*64
print n.w
print(i, 'o'*64)
print(n.w)
pass
print 'o'*64
print('o'*64)
pass
pass
......@@ -212,14 +212,14 @@ if __name__ == '__main__':
# nn.train((x, y, d), eta, epsilon, nEpoch)
print '-'*64
print nn
print '-'*64
print('-'*64)
print(nn)
print('-'*64)
for i in range(len(x)):
o = nn.compute(x[i])
print 'x[i]:', x[i]
print 'y[i]:', y[i], 'o:', o
print('x[i]:', x[i])
print('y[i]:', y[i], 'o:', o)
pass
# print 'rmse', nn.test((x, y))
......@@ -257,23 +257,23 @@ if __name__ == '__main__':
for i in range(len(x)):
o = nn.compute(x[i])
print x[i]
print y[i], o
print(x[i])
print(y[i], o)
print '&'*64
print('&'*64)
s = nn
print s
print(s)
print '&'*64
print('&'*64)
nn.fromStr(s)
print nn
print(nn)
nn.dump()
for i in range(len(x)):
o = nn.compute(x[i])
print x[i]
print y[i], o
print(x[i])
print(y[i], o)
pass
......
......@@ -5,7 +5,7 @@ Created on Mar 4, 2012
'''
from random import random
from Activation import f
from .Activation import f
import json
class Neuron(object):
......@@ -119,22 +119,22 @@ if __name__ == '__main__':
n.backProp(eta, 1)
pass
print k, err
print(k, err)
pass
print n
print(n)
for i in range(len(x)):
print x[i], y[i], n.compute(x[i])
print(x[i], y[i], n.compute(x[i]))
print '^'*64
print('^'*64)
s = str(n)
print s
print(s)
n.__init__(0)
n.fromStr(s)
for i in range(len(x)):
print x[i], y[i], n.compute(x[i])
print(x[i], y[i], n.compute(x[i]))
exit(0)
pass
......@@ -4,7 +4,7 @@ Created on Jul 31, 2012
@author: hadianeh
'''
from Var import Var
from .Var import Var
class Code(object):
def __init__(self):
......@@ -34,7 +34,7 @@ class Code(object):
def toCpp(self, path, nn, targetConfig, vectorMode):
try: f = open(path, 'w')
except:
print 'Error: Oops! Cannot open ' + path + '!'
print('Error: Oops! Cannot open ' + path + '!')
return False
pass
......@@ -54,7 +54,7 @@ class Code(object):
if (vectorMode):
vectorDataType = targetConfig.get('vectorDataType')
vVars = list(self.vVars.iterkeys())
vVars = list(self.vVars.keys())
vVars.sort()
for v in vVars:
s += 'static ' + vectorDataType + ' ' + v
......@@ -79,7 +79,7 @@ class Code(object):
s += 'static ' + dataType + ' ' + 'y_tmp' + '[' + str(targetConfig.get('vectorWidth')) + '] __attribute__ ((aligned(32)));\n'
s += '\n'
else:
for v, n in Var.varTrack.iteritems():
for v, n in Var.varTrack.items():
s += 'static ' + dataType + ' ' + v + '[' + str(n) + '];\n'
s += '\n'
pass
......
......@@ -5,8 +5,8 @@ Created on Jul 30, 2012
'''
import json
from Var import Var
from Code import Code
from .Var import Var
from .Code import Code
class Inst(object):
def __init__(self, opr='', type='s', fn = ''):
......@@ -153,7 +153,7 @@ class Inst(object):
pass
def cppAvx(self, dataType, tabs = 1):
print self
print(self)
#raw_input()
s = '\t'*tabs
......@@ -216,17 +216,17 @@ class Inst(object):
for i, oprList in enumerate([self.dst, self.src1, self.src2]):
oprClass = oprList[0].var
print oprClass
print(oprClass)
oprNames = [o.name('', True) for o in oprList]
oprId = '_' + '_'.join(oprNames)
print oprId, oprNames
print(oprId, oprNames)
oprValues = [o.value for o in oprList]
print oprValues
print(oprValues)
oprIndices = [o.desc[-1] for o in oprList]
print oprIndices
print(oprIndices)
if (not oprClass == ''):
try:
......@@ -366,8 +366,8 @@ if __name__ == '__main__':
i.src1 = Var('w', (0, 2))
i.src2 = Var('m', (0, 2))
print i
print i.dst.name(), i.src1.name(), i.src2.name()
print(i)
print(i.dst.name(), i.src1.name(), i.src2.name())
exit(0)
pass
......@@ -24,7 +24,7 @@ class JsonCloak(object):
try: inFile = open(filePath)
except:
inFile = None
print('Error! Oops! Cannot open ' + str(filePath) + '!')
print(('Error! Oops! Cannot open ' + str(filePath) + '!'))
return
pass
......@@ -36,7 +36,7 @@ class JsonCloak(object):
try: outFile = open(filePath, 'w')
except:
outFile = None
print('Error! Oops! Cannot open ' + filePath + '!')
print(('Error! Oops! Cannot open ' + filePath + '!'))
return
pass
......
......@@ -65,8 +65,8 @@ f = {
}
if __name__ == '__main__':
print f['sigmoid'][0](-100, 10)
print f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10)
print(f['sigmoid'][0](-100, 10))
print(f['sigmoid'][1](-100, f['sigmoid'][0](-100, 10), 10))
exit(0)
pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment