Skip to content
Snippets Groups Projects
Commit c7b1ac98 authored by hl00586's avatar hl00586
Browse files

remove cached files

parent 4b9378b8
No related branches found
No related tags found
No related merge requests found
No preview for this file type
results/mnist/result.png

40.8 KiB | W: | H:

results/mnist/result.png

40 KiB | W: | H:

results/mnist/result.png
results/mnist/result.png
results/mnist/result.png
results/mnist/result.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -2,13 +2,19 @@ from keras.models import Model ...@@ -2,13 +2,19 @@ from keras.models import Model
from keras.layers import Dense, Input, Conv2D, Flatten, MaxPooling2D from keras.layers import Dense, Input, Conv2D, Flatten, MaxPooling2D
from configuration import conf from configuration import conf
from utils.dataloader import Sequential_loader from utils.dataloader import Sequential_loader
import numpy as np
from utils.model_utils import mask_layer_by_task from utils.model_utils import mask_layer_by_task
from utils.layers import Probability_CLF_Mul_by_task from utils.layers import Probability_CLF_Mul_by_task
from utils.train_utils import train_with_task from utils.train_utils import train_with_task
from utils.predict_utils import get_task_likelihood, get_test_acc from utils.predict_utils import get_task_likelihood, get_test_acc
from utils.utils import paa, mkdir
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set()
PATH = './results/%s/' % conf.dataset_name PATH = './results/%s/' % conf.dataset_name
mkdir(PATH)
epochs = 10 epochs = 10
output_dim = 10 output_dim = 10
...@@ -52,24 +58,9 @@ for task_idx in range(conf.num_tasks): ...@@ -52,24 +58,9 @@ for task_idx in range(conf.num_tasks):
test_acc.append(get_test_acc(model, learned_task=task_idx, data_loader=data_loader, test_on_whole_set=False)) test_acc.append(get_test_acc(model, learned_task=task_idx, data_loader=data_loader, test_on_whole_set=False))
# Print the average test accuracy across all the tasks # Print the average test accuracy across all the tasks
print('Learned %dth Task, Average test accuracy on all the task : %.3f' % ( print('Learned %dth Task, Average test accuracy on all the task : %.3f' % (
task_idx, get_test_acc(model, learned_task=task_idx, data_loader=data_loader, test_on_whole_set=True))) task_idx, get_test_acc(model, learned_task=task_idx, data_loader=data_loader, test_on_whole_set=True)))
def paa(sample, w=None):
w = sample.shape[0] // 20 if w is None else w
l = len(sample)
stepfloat = l / w
step = int(np.ceil(stepfloat))
start = 0
j = 1
paa = []
while start <= (l - step):
section = sample[start:start + step]
paa.append(np.mean(section))
start = int(j * stepfloat)
j += 1
return paa
# Plot the result
tlh_s = [] tlh_s = []
for i in tlh: for i in tlh:
...@@ -80,14 +71,8 @@ tlh_std_s = [] ...@@ -80,14 +71,8 @@ tlh_std_s = []
for i in tlh_std: for i in tlh_std:
tlh_std_s += i.tolist() tlh_std_s += i.tolist()
tlh_std_s = np.array(tlh_std_s) tlh_std_s = np.array(tlh_std_s)
test_acc_s = np.array(test_acc).reshape(-1) test_acc_s = np.array(test_acc).reshape(-1)
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
tlh = np.array(paa(tlh_s)) tlh = np.array(paa(tlh_s))
tlh_std = np.array(paa(tlh_std_s)) tlh_std = np.array(paa(tlh_std_s))
test_acc = np.array(paa(test_acc_s, tlh.shape[0])) test_acc = np.array(paa(test_acc_s, tlh.shape[0]))
...@@ -100,7 +85,6 @@ for i in a: ...@@ -100,7 +85,6 @@ for i in a:
fig.fill_between(np.arange(i, i + 10 + 1), 0, 0.1, alpha=0.1, color='red') fig.fill_between(np.arange(i, i + 10 + 1), 0, 0.1, alpha=0.1, color='red')
fig.fill_between(np.arange(i - 10, i + 1), 0, 0.1, alpha=0.1, color='green') fig.fill_between(np.arange(i - 10, i + 1), 0, 0.1, alpha=0.1, color='green')
fig.fill_between(np.arange(90 - 10, 90), 0, 0.1, alpha=0.1, color='green') fig.fill_between(np.arange(90 - 10, 90), 0, 0.1, alpha=0.1, color='green')
# a = fig.get_xticklabels()
fig.set_xticklabels(['', 'Task 1', 'Task 2', 'Task 3', 'Task 4', 'Task 5']) fig.set_xticklabels(['', 'Task 1', 'Task 2', 'Task 3', 'Task 4', 'Task 5'])
plt.legend(loc='center right') plt.legend(loc='center right')
plt.savefig(PATH + 'result') plt.savefig(PATH + 'result')
......
No preview for this file type
No preview for this file type
import os import os
import numpy as np
def mkdir(path): def mkdir(path):
""" Create a directory if there isn't one already. """ """ Create a directory if there isn't one already. """
try: try:
os.mkdir(path) os.mkdir(path)
except OSError: except OSError:
pass pass
\ No newline at end of file
def paa(sample, w=None):
w = sample.shape[0] // 20 if w is None else w
l = len(sample)
stepfloat = l / w
step = int(np.ceil(stepfloat))
start = 0
j = 1
paa = []
while start <= (l - step):
section = sample[start:start + step]
paa.append(np.mean(section))
start = int(j * stepfloat)
j += 1
return paa
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment