def test_keras_export(self):
tests = open(os.path.join(settings.BASE_DIR, 'tests', 'unit', 'keras_app',
'keras_export_test.json'), 'r')
response = json.load(tests)
tests.close()
net = yaml.safe_load(json.dumps(response['net']))
net = {'l0': net['Input'], 'l1': net['BatchNorm'], 'l2': net['Scale']}
net['l0']['connection']['output'].append('l1')
# Test 1
inp = data(net['l0'], '', 'l0')['l0']
temp = batch_norm(net['l1'], [inp], 'l1', 'l2', net['l2'])
model = Model(inp, temp['l2'])
self.assertEqual(model.layers[1].__class__.__name__, 'BatchNormalization')
# Test 2
net['l2']['params']['filler'] = 'VarianceScaling'
net['l2']['params']['bias_filler'] = 'VarianceScaling'
inp = data(net['l0'], '', 'l0')['l0']
temp = batch_norm(net['l1'], [inp], 'l1', 'l2', net['l2'])
model = Model(inp, temp['l2'])
self.assertEqual(model.layers[1].__class__.__name__, 'BatchNormalization')
# Test 3
inp = data(net['l0'], '', 'l0')['l0']
temp = batch_norm(net['l1'], [inp], 'l1', 'l0', net['l0'])
model = Model(inp, temp['l1'])
self.assertEqual(model.layers[1].__class__.__name__, 'BatchNormalization')
评论列表
文章目录