def test_keras_import(self):
model = Sequential()
model.add(LSTM(64, return_sequences=True, input_shape=(10, 64)))
model.add(SimpleRNN(32, return_sequences=True))
model.add(GRU(10, kernel_regularizer=regularizers.l2(0.01),
bias_regularizer=regularizers.l2(0.01), recurrent_regularizer=regularizers.l2(0.01),
activity_regularizer=regularizers.l2(0.01), kernel_constraint='max_norm',
bias_constraint='max_norm', recurrent_constraint='max_norm'))
model.build()
json_string = Model.to_json(model)
with open(os.path.join(settings.BASE_DIR, 'media', 'test.json'), 'w') as out:
json.dump(json.loads(json_string), out, indent=4)
sample_file = open(os.path.join(settings.BASE_DIR, 'media', 'test.json'), 'r')
response = self.client.post(reverse('keras-import'), {'file': sample_file})
response = json.loads(response.content)
layerId = sorted(response['net'].keys())
self.assertEqual(response['result'], 'success')
self.assertGreaterEqual(len(response['net'][layerId[1]]['params']), 7)
self.assertGreaterEqual(len(response['net'][layerId[3]]['params']), 7)
self.assertGreaterEqual(len(response['net'][layerId[6]]['params']), 7)
# ********** Embedding Layers **********
评论列表
文章目录