From 2bf21045427d508694d3d087dd62f5116f2f97e0 Mon Sep 17 00:00:00 2001 From: XavierCooney Date: Thu, 1 Nov 2018 22:32:45 +1100 Subject: [PATCH 1/3] Fix broken markdown link in tested_models.md (#417) --- docs/source/tested_models.md | 2 +- tutorials/tested_models.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/tested_models.md b/docs/source/tested_models.md index c028803d0..8a8be3587 100644 --- a/docs/source/tested_models.md +++ b/docs/source/tested_models.md @@ -46,7 +46,7 @@ ## Segmentation * Image Segmentation CRF-RNN [\[Source\]](https://github.com/torrvision/crfasrnn/tree/master/python-scripts)[\[Visualise\]](http://fabrik.cloudcv.org/caffe/load?id=20180111183110okaux) -* UNET [\[Source\]](https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model)[\[Visualise]](http://fabrik.cloudcv.org/caffe/load?id=20180116070834rggzh) +* UNET [\[Source\]](https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model)[\[Visualise\]](http://fabrik.cloudcv.org/caffe/load?id=20180116070834rggzh) ### Miscellaneous diff --git a/tutorials/tested_models.md b/tutorials/tested_models.md index 0510e1342..f8fc5dc6a 100644 --- a/tutorials/tested_models.md +++ b/tutorials/tested_models.md @@ -49,7 +49,7 @@ ## Segmentation * Image Segmentation CRF-RNN [\[Source\]](https://github.com/torrvision/crfasrnn/tree/master/python-scripts)[\[Visualise\]](http://fabrik.cloudcv.org/caffe/load?id=20180111183110okaux) -* UNET [\[Source\]](https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model)[\[Visualise]](http://fabrik.cloudcv.org/caffe/load?id=20180116070834rggzh) +* UNET [\[Source\]](https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model)[\[Visualise\]](http://fabrik.cloudcv.org/caffe/load?id=20180116070834rggzh) ### Miscellaneous From b68ee9430652379b1590f4d1eeea19b86db6c6bc Mon Sep 17 00:00:00 2001 From: Bharath Raj Date: Mon, 5 Nov 2018 10:34:01 +0530 Subject: [PATCH 2/3] Added Slice layer to pane.js (#425) --- ide/static/js/pane.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ide/static/js/pane.js b/ide/static/js/pane.js index 2f1f96217..6090f6996 100644 --- a/ide/static/js/pane.js +++ b/ide/static/js/pane.js @@ -250,6 +250,9 @@ class Pane extends React.Component { Masking + Slice From 4b7e3edd8174a3ca7b001f015d1f3a5ed7bf5399 Mon Sep 17 00:00:00 2001 From: Abhigyan Bhusal Date: Mon, 5 Nov 2018 15:19:10 +0545 Subject: [PATCH 3/3] Added linear activation support for Keras (#426) * Add PaneElement for linear activation * Add linear activation layer data to data.js * Add support for export of Linear activation layer to keras * Add support for import of Linear activation layer from keras * Add unit tests for linear activation layer * Fix comment formatting * add Linear activation to layer map in export_json.py --- ide/static/js/data.js | 30 +++++++++++++++++++++ ide/static/js/pane.js | 3 +++ ide/tasks.py | 1 + keras_app/views/export_json.py | 1 + keras_app/views/import_json.py | 1 + keras_app/views/layers_export.py | 2 ++ keras_app/views/layers_import.py | 3 ++- tests/unit/keras_app/keras_export_test.json | 15 +++++++++++ tests/unit/keras_app/test_views.py | 23 ++++++++++++++++ 9 files changed, 78 insertions(+), 1 deletion(-) diff --git a/ide/static/js/data.js b/ide/static/js/data.js index b9bb5d410..41bfb7119 100644 --- a/ide/static/js/data.js +++ b/ide/static/js/data.js @@ -3065,6 +3065,36 @@ export default { }, learn: true }, + Linear: { // Only Keras + name: 'linear', + color: '#009688', + endpoint: { + src: ['Bottom'], + trg: ['Top'] + }, + params: { + inplace: { + name: 'Inplace operation', + value: true, + type: 'checkbox', + required: false + }, + caffe: { + name: 'Available Caffe', + value: false, + type: 'checkbox', + required: false + } + }, + props: { + name: { + name: 'Name', + value: '', + type: 'text' + } + }, + learn: false + }, /* ********** Utility Layers ********** */ Flatten: { name: 'flatten', diff --git a/ide/static/js/pane.js b/ide/static/js/pane.js index 6090f6996..0b5436407 100644 --- a/ide/static/js/pane.js +++ b/ide/static/js/pane.js @@ -322,6 +322,9 @@ class Pane extends React.Component { Scale + Linear diff --git a/ide/tasks.py b/ide/tasks.py index ecc46fa0c..24fe8c8df 100644 --- a/ide/tasks.py +++ b/ide/tasks.py @@ -78,6 +78,7 @@ def export_keras_json(net, net_name, is_tf, reply_channel): 'TanH': activation, 'Sigmoid': activation, 'HardSigmoid': activation, + 'Linear': activation, 'Dropout': dropout, 'Flatten': flatten, 'Reshape': reshape, diff --git a/keras_app/views/export_json.py b/keras_app/views/export_json.py index af8913fea..216879ce3 100644 --- a/keras_app/views/export_json.py +++ b/keras_app/views/export_json.py @@ -49,6 +49,7 @@ def export_json(request, is_tf=False): 'TanH': activation, 'Sigmoid': activation, 'HardSigmoid': activation, + 'Linear': activation, 'Dropout': dropout, 'Flatten': flatten, 'Reshape': reshape, diff --git a/keras_app/views/import_json.py b/keras_app/views/import_json.py index d8b919884..561b85e93 100644 --- a/keras_app/views/import_json.py +++ b/keras_app/views/import_json.py @@ -62,6 +62,7 @@ def import_json(request): 'tanh': Activation, 'sigmoid': Activation, 'hard_sigmoid': Activation, + 'linear': Activation, 'Dropout': Dropout, 'Flatten': Flatten, 'Reshape': Reshape, diff --git a/keras_app/views/layers_export.py b/keras_app/views/layers_export.py index 257065610..9d126b911 100644 --- a/keras_app/views/layers_export.py +++ b/keras_app/views/layers_export.py @@ -123,6 +123,8 @@ def activation(layer, layer_in, layerId, tensor=True): out[layerId] = Activation('softsign') elif (layer['info']['type'] == 'HardSigmoid'): out[layerId] = Activation('hard_sigmoid') + elif (layer['info']['type'] == 'Linear'): + out[layerId] = Activation('linear') if tensor: out[layerId] = out[layerId](*layer_in) return out diff --git a/keras_app/views/layers_import.py b/keras_app/views/layers_import.py index 7be30f85c..d32b45d6e 100644 --- a/keras_app/views/layers_import.py +++ b/keras_app/views/layers_import.py @@ -41,7 +41,8 @@ def Activation(layer): 'selu': 'SELU', 'softplus': 'Softplus', 'softsign': 'Softsign', - 'hard_sigmoid': 'HardSigmoid' + 'hard_sigmoid': 'HardSigmoid', + 'linear': 'Linear' } if (layer.__class__.__name__ == 'Activation'): return jsonLayer(activationMap[layer.activation.func_name], {}, layer) diff --git a/tests/unit/keras_app/keras_export_test.json b/tests/unit/keras_app/keras_export_test.json index c778c2045..ca49615d0 100644 --- a/tests/unit/keras_app/keras_export_test.json +++ b/tests/unit/keras_app/keras_export_test.json @@ -777,6 +777,21 @@ "inplace": true } }, + "Linear": { + "connection": { + "input": [ + "l0" + ], + "ouput": [] + }, + "info": { + "phase": null, + "type": "Linear" + }, + "params": { + "inplace": true + } + }, "Upsample": { "info": { "phase": null, diff --git a/tests/unit/keras_app/test_views.py b/tests/unit/keras_app/test_views.py index d5237a7f2..c21b420ff 100644 --- a/tests/unit/keras_app/test_views.py +++ b/tests/unit/keras_app/test_views.py @@ -285,6 +285,11 @@ def test_keras_import(self): model.add(ThresholdedReLU(theta=1, input_shape=(15,))) model.build() self.keras_type_test(model, 0, 'ThresholdedReLU') + # Linear + model = Sequential() + model.add(Activation('linear', input_shape=(15,))) + model.build() + self.keras_type_test(model, 0, 'Linear') class DropoutImportTest(unittest.TestCase, HelperFunctions): @@ -943,6 +948,24 @@ def test_keras_export(self): self.assertEqual(model.layers[1].__class__.__name__, 'Activation') +class LinearActivationExportTest(unittest.TestCase): + def setUp(self): + self.client = Client() + + 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['Linear']} + net['l0']['connection']['output'].append('l1') + inp = data(net['l0'], '', 'l0')['l0'] + net = activation(net['l1'], [inp], 'l1') + model = Model(inp, net['l1']) + self.assertEqual(model.layers[1].__class__.__name__, 'Activation') + + class DropoutExportTest(unittest.TestCase): def setUp(self): self.client = Client()