Class: Transformers::Vit::ViTOutput

Inherits:
Torch::NN::Module
  • Object
show all
Defined in:
lib/transformers/models/vit/modeling_vit.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ViTOutput

Returns a new instance of ViTOutput.



226
227
228
229
230
# File 'lib/transformers/models/vit/modeling_vit.rb', line 226

def initialize(config)
  super()
  @dense = Torch::NN::Linear.new(config.intermediate_size, config.hidden_size)
  @dropout = Torch::NN::Dropout.new(p: config.hidden_dropout_prob)
end

Instance Method Details

#forward(hidden_states, input_tensor) ⇒ Object



232
233
234
235
236
237
238
239
# File 'lib/transformers/models/vit/modeling_vit.rb', line 232

def forward(hidden_states, input_tensor)
  hidden_states = @dense.(hidden_states)
  hidden_states = @dropout.(hidden_states)

  hidden_states = hidden_states + input_tensor

  hidden_states
end