Class: Transformers::Bert::BertIntermediate

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ BertIntermediate

Returns a new instance of BertIntermediate.



256
257
258
259
260
261
262
263
264
# File 'lib/transformers/models/bert/modeling_bert.rb', line 256

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



266
267
268
269
270
# File 'lib/transformers/models/bert/modeling_bert.rb', line 266

def forward(hidden_states)
  hidden_states = @dense.(hidden_states)
  hidden_states = @intermediate_act_fn.(hidden_states)
  hidden_states
end