From f0b09dc4025be9f0c45a59a281ce1cb41511ac3c Mon Sep 17 00:00:00 2001 From: Dmitry Ulyanov Date: Fri, 14 Oct 2016 00:07:35 +0300 Subject: [PATCH 1/3] Fix default parameter in GramMatrix module Expression `normalize or true` always evaluates to `true`. The correct way is like here https://github.com/torch/nn/blob/master/BatchNormalization.lua#L44 --- fast_neural_style/GramMatrix.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fast_neural_style/GramMatrix.lua b/fast_neural_style/GramMatrix.lua index 99e461e..3e7da9b 100644 --- a/fast_neural_style/GramMatrix.lua +++ b/fast_neural_style/GramMatrix.lua @@ -18,7 +18,12 @@ Output: function Gram:__init(normalize) parent.__init(self) - self.normalize = normalize or true + if normalize ~= nil then + assert(type(normalize) == 'boolean', 'normalize has to be true/false') + self.normalize = normalize + else + self.normalize = true + end self.buffer = torch.Tensor() end From d9033b9b3f0c72fe75d2f6e8130d06e84f83f2cb Mon Sep 17 00:00:00 2001 From: houxianxu Date: Mon, 17 Oct 2016 11:30:06 +0800 Subject: [PATCH 2/3] remove loadcaffe --- train.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/train.lua b/train.lua index 4b45400..58a2735 100644 --- a/train.lua +++ b/train.lua @@ -1,5 +1,4 @@ require 'torch' -require 'loadcaffe' require 'optim' require 'image' From cafb5ed4f4cb620178b0d9a16b289cec2aac4b4c Mon Sep 17 00:00:00 2001 From: romawhite47 Date: Mon, 17 Oct 2016 11:21:54 +0300 Subject: [PATCH 3/3] Pass agg_type to StyleLoss init --- fast_neural_style/PerceptualCriterion.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast_neural_style/PerceptualCriterion.lua b/fast_neural_style/PerceptualCriterion.lua index 0321740..af6f604 100644 --- a/fast_neural_style/PerceptualCriterion.lua +++ b/fast_neural_style/PerceptualCriterion.lua @@ -46,7 +46,7 @@ function crit:__init(args) -- Set up style loss layers for i, layer_string in ipairs(args.style_layers) do local weight = args.style_weights[i] - local style_loss_layer = nn.StyleLoss(weight, args.loss_type) + local style_loss_layer = nn.StyleLoss(weight, args.loss_type, args.agg_type) layer_utils.insert_after(self.net, layer_string, style_loss_layer) table.insert(self.style_loss_layers, style_loss_layer) end