-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunitTest.py
120 lines (90 loc) · 2.32 KB
/
unitTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# %%
from task.base.TaskLoader import Opt
from models.base._baseSetting import hyper
hyper = hyper()
hyper.addopt = 'one'
hyper.bopt ='bopt'
class Base():
def __init__(self, hyper) -> None:
self.hyper = hyper
def forward(self, x):
# x = x / x.norm(p=2, dim=-1, keepdim=True)
return x
def _xfit(self, a = None, b = None):
print("this is from base",a, b)
fit_info = Opt()
fit_info.a = a
fit_info.b = b
return fit_info
class son_a(Base):
def __init__(self, hyper = None):
super().__init__(hyper)
def add(self,):
self.mask = ['1', '2']
class son_b(Base):
def __init__(self, hyper = None):
super().__init__(hyper)
self.bopt = hyper.bopt
def _xfit(self, a = None, b = None):
print("this is from son b",a, b)
fit_info = Opt()
fit_info.a = a
fit_info.b = b
return fit_info
class son_c(son_a, son_b):
def __init__(self, hyper = None):
super().__init__(hyper)
self.add()
def fit(self, a = 1, b = 1):
# self.add()
self._xfit(a, b)
son = son_c(hyper)
son.fit()
# %%
# import tensorflow as tf
# from tensorflow.python.keras.layers import MaxPooling1D
# x = tf.constant([x * 0.1 for x in range(128)])
# x = tf.reshape(x, [1, 1, 128])
# max_pool_1d = MaxPooling1D(data_format='channels_first')
# y = max_pool_1d(x)
# print(y)
# %%
# print(x)
# max_pool_1d(x)
# %%
class test():
@staticmethod
def sig_len():
"""
docstring
"""
return 128
print(test.sig_len)
# %%
a = {'a':1}
b = a.copy()
b['a'] = 2
print(a)
print(b)
for key in a.keys():
print(key)
# %%
from collections import Counter
inputMask = [0, 1, 0, 1, 1, 1]
inputStep_count = Counter(inputMask)
inputMask_Pos = inputStep_count[1]
Neg = inputStep_count[0]
print(inputStep_count)
print(inputMask_Pos)
print(Neg)
# %%
import torch,os
from task.base.TaskLoader import Opt
hyper = Opt()
config = {'inputMask_{}'.format(i) : 1 for i in range(128)}
hyper.merge(config)
hyper.dict['inputMask_127'] = 0
hyper.dict['inputMask_79'] = 0
tuner_algo_dir = 'exp_tempTest/RML2016.10a/ICASSP24.amcnet.maskcut/fit/amcnet/tuner/tpe/maskTuningCell_46bf3957'
torch.save(hyper, os.path.join(tuner_algo_dir, 'hyper.pt'))
# %%