From 3be5d8c7acccdf781ebda582d17f6c010944a9b0 Mon Sep 17 00:00:00 2001 From: databay Date: Thu, 21 Jan 2016 17:43:32 +0100 Subject: [PATCH] fix save and load function --- python/pyrenn.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/pyrenn.py b/python/pyrenn.py index e9c4bc8..d9ceecb 100644 --- a/python/pyrenn.py +++ b/python/pyrenn.py @@ -876,8 +876,8 @@ def saveNN(net,filename): import pandas as pd #create csv write - file = open(filename,"wb") - writer = csv.writer(file) + file = open(filename,"w") + writer = csv.writer(file, lineterminator='\n') #write network structure nn @@ -912,6 +912,9 @@ def saveNN(net,filename): #write weight vector w writer.writerow(['w']) + file.close() + + file = open(filename,"ab") np.savetxt(file,net['w'],delimiter=',',fmt='%.55f') #close file @@ -931,7 +934,7 @@ def loadNN(filename): import pandas as pd #read csv - data= list(csv.reader(open(filename,"rb"))) + data= list(csv.reader(open(filename,"r"))) #read network structure nn nn = list(np.array(data[1],dtype=np.int))