Class: Transformers::Vit::ViTIntermediate
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- Transformers::Vit::ViTIntermediate
- Defined in:
- lib/transformers/models/vit/modeling_vit.rb
Instance Method Summary collapse
- #forward(hidden_states) ⇒ Object
-
#initialize(config) ⇒ ViTIntermediate
constructor
A new instance of ViTIntermediate.
Constructor Details
#initialize(config) ⇒ ViTIntermediate
Returns a new instance of ViTIntermediate.
207 208 209 210 211 212 213 214 215 |
# File 'lib/transformers/models/vit/modeling_vit.rb', line 207 def initialize(config) super() @dense = Torch::NN::Linear.new(config.hidden_size, config.intermediate_size) if config.hidden_act.is_a?(String) @intermediate_act_fn = ACT2FN[config.hidden_act] else @intermediate_act_fn = config.hidden_act end end |
Instance Method Details
#forward(hidden_states) ⇒ Object
217 218 219 220 221 222 |
# File 'lib/transformers/models/vit/modeling_vit.rb', line 217 def forward(hidden_states) hidden_states = @dense.(hidden_states) hidden_states = @intermediate_act_fn.(hidden_states) hidden_states end |