-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmodels_test.py
66 lines (53 loc) · 1.97 KB
/
models_test.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
import os
import tensorflow as tf
from models import *
class ModelsTest(tf.test.TestCase):
def test_seldnet(self):
raise NotImplemented()
def test_seldnet_v1(self):
raise NotImplemented()
def test_conv_temporal(self):
raise NotImplemented()
def test_vad_architecture(self):
input_shape = [7, 80, 1] # win_size, n_mels
model_config = {
'flatten': True,
'last_unit': 7,
'BLOCK0': 'simple_dense_stage',
'BLOCK0_ARGS': {
'depth': 2,
'units': 512,
'dense_activation': 'relu',
'dropout_rate': 0.5,
}
}
vad = vad_architecture(input_shape, model_config)
self.assertEqual(vad.output_shape[1:], (7,))
model_config = {
'flatten': False,
'last_unit': 1,
'BLOCK0': 'simple_dense_stage',
'BLOCK0_ARGS': {
'depth': 2,
'units': 512,
'dense_activation': 'relu',
'dropout_rate': 0.5,
}
}
vad = vad_architecture(input_shape, model_config)
self.assertEqual(vad.output_shape[1:], (7,))
def test_spectro_temporal_attention_based_VAD(self):
input_shape = [7, 80, 1] # win_size, n_mels
model_config = {}
vad = spectro_temporal_attention_based_VAD(input_shape, model_config)
self.assertEqual(vad.output_shape[0][1:], (7, 1))
self.assertEqual(vad.output_shape[1][1:], (7, 1))
self.assertEqual(vad.output_shape[2][1:], (7,))
# test its trainability
x = tf.random.uniform([32, 7, 80, 1])
y = tf.random.uniform([32, 7], maxval=2, dtype=tf.int32)
vad.compile('adam', loss=tf.keras.losses.BinaryCrossentropy())
vad.fit(x, y)
if __name__ == '__main__':
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
tf.test.main()