Class: Transformers::Vit::ViTOutput
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::Vit::ViTOutput
- Defined in:
- lib/transformers/models/vit/modeling_vit.rb
Instance Method Summary collapse
- #forward(hidden_states, input_tensor) ⇒ Object
-
#initialize(config) ⇒ ViTOutput
constructor
A new instance of ViTOutput.
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 |