aboutsummaryrefslogblamecommitdiff
path: root/nerv/layer/sigmoid.lua
blob: 5974ffca45ee67f0c17dc2f1e34d3f14898c3aee (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                                                                  
                                                         
                                                        
                            


                                                                

   



                                   


                            



                                              



                                                   
                                              
                               

   
                                                                        
                                                     
   

                                  
                                            
   
local SigmoidLayer = nerv.class("nerv.SigmoidLayer", "nerv.Layer")

function SigmoidLayer:__init(id, global_conf, layer_conf)
    nerv.Layer.__init(self, id, global_conf, layer_conf)
    self:check_dim_len(1, 1)
    if self.dim_in[1] ~= self.dim_out[1] then
        nerv.error("mismatching dimensions of input and output")
    end
end

function SigmoidLayer:bind_params()
    -- do nothing
end

function SigmoidLayer:init()
end

function SigmoidLayer:batch_resize(batch_size)
    -- do nothing
end

function SigmoidLayer:update(bp_err, input, output)
    -- no params, therefore do nothing
end

function SigmoidLayer:propagate(input, output)
    output[1]:sigmoid(input[1])
end

function SigmoidLayer:back_propagate(bp_err, next_bp_err, input, output)
    next_bp_err[1]:sigmoid_grad(bp_err[1], output[1])
end

function SigmoidLayer:get_params()
    return nerv.ParamRepo({}, self.loc_type)
end