{"action":"created","issue":{"url":"https://api.github.com/repos/vlfeat/matconvnet/issues/396","repository_url":"https://api.github.com/repos/vlfeat/matconvnet","labels_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/396/labels{/name}","comments_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/396/comments","events_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/396/events","html_url":"https://github.com/vlfeat/matconvnet/issues/396","id":130360667,"number":396,"title":"Dagnn Customized loss Layer","user":{"login":"pramodyn","id":9526618,"avatar_url":"https://avatars.githubusercontent.com/u/9526618?v=3","gravatar_id":"","url":"https://api.github.com/users/pramodyn","html_url":"https://github.com/pramodyn","followers_url":"https://api.github.com/users/pramodyn/followers","following_url":"https://api.github.com/users/pramodyn/following{/other_user}","gists_url":"https://api.github.com/users/pramodyn/gists{/gist_id}","starred_url":"https://api.github.com/users/pramodyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pramodyn/subscriptions","organizations_url":"https://api.github.com/users/pramodyn/orgs","repos_url":"https://api.github.com/users/pramodyn/repos","events_url":"https://api.github.com/users/pramodyn/events{/privacy}","received_events_url":"https://api.github.com/users/pramodyn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-02-01T13:20:31Z","updated_at":"2016-12-22T09:29:55Z","closed_at":"2016-12-16T08:48:58Z","body":"How can i define a Customized Loss Layer in DAGnn setup? In a Simplenn framework, it was easy by defining the Forward and Backward functions. How do we do it in DAGnn Framework?\n"},"comment":{"url":"https://api.github.com/repos/vlfeat/matconvnet/issues/comments/268757008","html_url":"https://github.com/vlfeat/matconvnet/issues/396#issuecomment-268757008","issue_url":"https://api.github.com/repos/vlfeat/matconvnet/issues/396","id":268757008,"user":{"login":"AruniRC","id":1054799,"avatar_url":"https://avatars.githubusercontent.com/u/1054799?v=3","gravatar_id":"","url":"https://api.github.com/users/AruniRC","html_url":"https://github.com/AruniRC","followers_url":"https://api.github.com/users/AruniRC/followers","following_url":"https://api.github.com/users/AruniRC/following{/other_user}","gists_url":"https://api.github.com/users/AruniRC/gists{/gist_id}","starred_url":"https://api.github.com/users/AruniRC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AruniRC/subscriptions","organizations_url":"https://api.github.com/users/AruniRC/orgs","repos_url":"https://api.github.com/users/AruniRC/repos","events_url":"https://api.github.com/users/AruniRC/events{/privacy}","received_events_url":"https://api.github.com/users/AruniRC/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T09:29:55Z","updated_at":"2016-12-22T09:29:55Z","body":"\r\nHere's the class definition for L2 loss\r\n\r\n    classdef L2Loss < dagnn.Loss\r\n    %LOSSREGUL Loss function for L2 loss between targets and activations\r\n    %   Detailed explanation goes here\r\n\r\n    properties\r\n        type = 'L2'\r\n    end\r\n\r\n    methods\r\n        function outputs = forward(obj, inputs, params)\r\n          outputs{1} = vl_nnL2(inputs{1}, inputs{2}, []) ;\r\n          n = obj.numAveraged ;\r\n          m = n + size(inputs{1},4) ;\r\n          obj.average = (n * obj.average + gather(outputs{1})) / m ;\r\n          obj.numAveraged = m ;\r\n        end\r\n\r\n        function [derInputs, derParams] = backward(obj, inputs, params, derOutputs)\r\n          derInputs{1} = vl_nnL2(inputs{1}, inputs{2}, derOutputs{1}) ;\r\n          derInputs{2} = [] ;\r\n          derParams = {} ;\r\n        end\r\n\r\n        function outputSizes = getOutputSizes(obj, inputSizes, paramSizes)\r\n          outputSizes{1} = [1 1 1 inputSizes{1}(4)] ;\r\n        end\r\n\r\n        function rfs = getReceptiveFields(obj)\r\n          % the receptive field depends on the dimension of the variables\r\n          % which is not known until the network is run\r\n          rfs(1,1).size = [NaN NaN] ;\r\n          rfs(1,1).stride = [NaN NaN] ;\r\n          rfs(1,1).offset = [NaN NaN] ;\r\n          rfs(2,1) = rfs(1,1) ;\r\n        end\r\n                                                     \r\nThe vl_nnL2() is based off #15 \r\n"}}
{"actor":{"display_login":"AruniRC"}}