Readme should indicate this work only in python 3.6 and greater
Closed this issue · 2 comments
WindowsPath doesnt integrate nicely into open until python 3.6.
EDIT 1: you could also wrap the open(windowsPath) methods with open(str(windowsPath))
Hi, thank you for the catch 👍 I totally forgot to update the minimum requirements. I think it should be good now so I'm closing the issue, but if you see any problems please message me.
You may want to consider performing additional metrics aside from the keras ones which are batch driven. For example, you could use the following code and compute AUC.
'''
def predict(model, generator, steps, numThreads=2, qSize=5):
numItemsPushed_predict = 0
dataQueue = queue.Queue(maxsize=qSize)
mutex = threading.Lock()
def producer(steps):
nonlocal numItemsPushed_predict
killMe = False
while True:
mutex.acquire()
if numItemsPushed_predict < steps:
numItemsPushed_predict += 1
else:
killMe = True
myUid = numItemsPushed_predict
mutex.release()
if killMe:
return
#
x, y = generator.next(myUid-1)
dataQueue.put((x,y,myUid-1))
#
#
#
tVec = []
for k in range(numThreads):
t = threading.Thread(target=producer, args=(steps,))
t.daemon = True
t.start()
tVec.append(t)
truthVec = None
predVec = None
batchSize = None
pBar = tqdm.tqdm(range(steps), desc='TEST')
for k in pBar:
currentQSize = dataQueue.qsize()
item = dataQueue.get()
x = item[0]
y = item[1]
uid = item[2] # TODO for ordering
if batchSize is None:
if type(x) is list:
batchSize = x[0].shape[0]
else:
batchSize = x.shape[0]
#
truthVec = np.zeros(batchSize*steps)
predVec = np.zeros(batchSize*steps)
y_pred = model.predict(x, batch_size = batchSize)
truthVec[uid*batchSize : (uid+1)*batchSize] = y.flatten()
if type(y_pred) is list:
predVec[uid*batchSize : (uid+1)*batchSize] = y_pred[0].flatten()
else:
predVec[uid*batchSize : (uid+1)*batchSize] = y_pred.flatten()
pBar.set_description('TEST | QSize: {0}/{1}'.format(currentQSize, qSize))
#
return truthVec, predVec
'''
aucRoc = metrics.auc(turthVec, predVec)
Additionally, use the above code, you could pass in generators instead of fixed data arrays. The above code works in Windows and Linux.