Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions wisard.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def printProgressBar(label,time,etime,basecolor, cursorcolor, linecnt,progress,s
str += color.END + cursorcolor + u'\u2588' + color.END + basecolor
else:
str += u'\u2591'
str += color.END + '| ' + "{:>3}".format(int(progress * 100.0)) + ' % ' + color.YELLOWBLACK + ' ' + etime + ' ' + color.WHITEBLACK + time + ' ' + color.END
sys.stdout.write("\r%s" % str.encode('utf-8'))
str += color.END + '| ' + "{:>3}".format(int(progress * 100.0)) + ' % ' + color.BLUE + ' ' + etime + ' ' + color.BLUE + time + ' ' + color.END
sys.stdout.write("\r%s" % str)
sys.stdout.flush()
return progress

Expand All @@ -42,21 +42,21 @@ def compTime(deltatime,progress):
tme = "{:0>2}:{:0>2}:{:02.0f}".format(int(hourse),int(minutese),secondse)
return tm,tme

def decide_onebyone((clf,data)):
def decide_onebyone(clf,data):
return [clf.wiznet_[cl].Classify(data, clf.ranges_, clf.offsets_, clf.notics) for cl in clf.classes_]

def decide_onebyone_noscale((clf,data)):
def decide_onebyone_noscale(clf,data):
return [clf.wiznet_[cl].ClassifyNoScale(data, clf.notics) for cl in clf.classes_]

def train_onebyone((clf,X,y)):
def train_onebyone(clf,X,y):
for i,data in enumerate(X):
clf.wiznet_[clf.classes_[y[i]]].Train(data,clf.ranges_,clf.offsets_, clf.notics)

def train_onebyone_noscale((clf,X,y)):
def train_onebyone_noscale(clf,X,y):
for i,data in enumerate(X):
clf.wiznet_[clf.classes_[y[i]]].TrainNoScale(data, self.notics)

def decide_onebyone_b((clf,data)):
def decide_onebyone_b(clf,data):
b = clf.b_def
confidence = 0.0
res_disc_list = [clf.wiznet_[cl].Response(data,clf.ranges_,clf.offsets_, clf.notics) for cl in clf.classes_]
Expand All @@ -76,7 +76,7 @@ def decide_onebyone_b((clf,data)):
result = np.array(result_partial)/result_sum
return result

def decide_onebyone_b_noscale((clf,data)):
def decide_onebyone_b_noscale(clf,data):
b = clf.b_def
confidence = 0.0
res_disc_list = [clf.wiznet_[cl].ResponseNoScale(data, clf.notics) for cl in clf.classes_]
Expand Down Expand Up @@ -402,7 +402,7 @@ def decision_function_par_b_noscale(self,X): # parallel version (no debug wit
def decision_function_seq_b(self,X): # sequential version (no debug with bleaching)
D = np.empty(shape=[0, len(self.classes_)])
for data in X:
res = decide_onebyone_b((self,data)) # classify with bleaching (Work in progress)
res = decide_onebyone_b(self,data) # classify with bleaching (Work in progress)
D = np.append(D, [res],axis=0)
return D

Expand Down Expand Up @@ -436,7 +436,7 @@ def decision_function_seq_b_debug(self,X):
self.starttm_ = time.time()
self.progress_ = 0.01
for data in X:
res = decide_onebyone_b((self,data)) # classify with bleaching (Work in progress)
res = decide_onebyone_b(self,data) # classify with bleaching (Work in progress)
D = np.append(D, [res],axis=0)
cnt += 1
tm,tme = compTime(time.time()-self.starttm_,self.progress_)
Expand All @@ -450,7 +450,7 @@ def decision_function_seq_b_debug_noscale(self,X):
self.starttm_ = time.time()
self.progress_ = 0.01
for data in X:
res = decide_onebyone_b_noscale((self,data)) # classify with bleaching (Work in progress)
res = decide_onebyone_b_noscale(self,data) # classify with bleaching (Work in progress)
D = np.append(D, [res],axis=0)
cnt += 1
tm,tme = compTime(time.time()-self.starttm_,self.progress_)
Expand Down
2 changes: 1 addition & 1 deletion wisard_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cdef extern from "Discriminator.h" namespace "wnn":
cdef class PyDiscriminator:
cdef Discriminator *thisptr # hold a C++ instance which we're wrapping
def __cinit__(self, bits, size, maptype="random"):
self.thisptr = new Discriminator(bits, size, maptype)
self.thisptr = new Discriminator(bits, size, maptype.encode('utf-8'))
def __dealloc__(self):
del self.thisptr
def getNBits(self):
Expand Down