Exemplo n.º 1
0
    num_batches = min(num_batches, params.num_batches)
for n in range(num_batches):
    x, y = sess.run([testset.x, testset.y])
    data.append(x)
    label.append(y)
data = np.concatenate(data, axis=0)
label = np.concatenate(label, axis=0)

masks, preds = dfa(data)
acc = (preds == np.expand_dims(label,axis=1)).astype(np.float32)

res = {
    'masks': masks,
    'preds': preds,
    'acc': acc
}
with gzip.open(f'{save_dir}/results.pgz', 'wb') as f:
    pickle.dump(res, f)

x = range(1, params.dimension+1)
y = np.mean(acc, axis=0)
fig = plt.figure()
plt.plot(x, y, marker='x')
plt.xticks(x)
plt.xlabel('num feature')
plt.ylabel('accuracy')
plt.savefig(f'{save_dir}/acc.png')
plt.close('all')

show_mask(masks, f'{save_dir}/mask.png')
Exemplo n.º 2
0
    masks.append(mask)
    preds.append(pred)
    acc.append((pred == np.expand_dims(y,axis=1)).astype(np.float32))
inds = np.concatenate(inds, axis=0)
masks = np.concatenate(masks, axis=0)
preds = np.concatenate(preds, axis=0)
acc = np.concatenate(acc, axis=0)

res = {
    'inds': inds,
    'masks': masks,
    'preds': preds,
    'acc': acc
}
with gzip.open(f'{save_dir}/results.pgz', 'wb') as f:
    pickle.dump(res, f)

x = range(1, params.time_steps+1)
y = np.mean(acc, axis=0)
fig = plt.figure()
plt.plot(x, y, marker='x')
plt.xticks(x)
plt.xlabel('time step')
plt.ylabel('accuracy')
plt.savefig(f'{save_dir}/acc.png')
plt.close('all')

B = masks.shape[0]
masks = np.reshape(masks, [B,params.time_steps,-1])
show_mask(masks[:,:,0], f'{save_dir}/mask.png')