Class: Torch::NN::GroupNorm
Instance Method Summary collapse
- #extra_inspect ⇒ Object
- #forward(input) ⇒ Object
-
#initialize(num_groups, num_channels, eps: 1e-5, affine: true) ⇒ GroupNorm
constructor
A new instance of GroupNorm.
- #reset_parameters ⇒ Object
Methods inherited from Module
#_apply, #add_module, #apply, #buffers, #call, #children, #cpu, #cuda, #double, #eval, #float, #half, #inspect, #load_state_dict, #method_missing, #modules, #named_buffers, #named_children, #named_modules, #named_parameters, #parameters, #register_buffer, #register_parameter, #requires_grad!, #respond_to?, #share_memory, #state_dict, #to, #train, #type, #zero_grad
Methods included from Utils
#_ntuple, #_pair, #_quadrupal, #_single, #_triple
Constructor Details
#initialize(num_groups, num_channels, eps: 1e-5, affine: true) ⇒ GroupNorm
Returns a new instance of GroupNorm.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/torch/nn/group_norm.rb', line 4 def initialize(num_groups, num_channels, eps: 1e-5, affine: true) super() @num_groups = num_groups @num_channels = num_channels @eps = eps @affine = affine if @affine @weight = Parameter.new(Torch::Tensor.new(num_channels)) @bias = Parameter.new(Torch::Tensor.new(num_channels)) else register_parameter("weight", nil) register_parameter("bias", nil) end reset_parameters end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Torch::NN::Module
Instance Method Details
#extra_inspect ⇒ Object
31 32 33 |
# File 'lib/torch/nn/group_norm.rb', line 31 def extra_inspect format("%{num_groups}, %{num_channels}, eps: %{eps}, affine: %{affine}", **dict) end |
#forward(input) ⇒ Object
27 28 29 |
# File 'lib/torch/nn/group_norm.rb', line 27 def forward(input) F.group_norm(input, @num_groups, weight: @weight, bias: @bias, eps: @eps) end |