Method: Transformers::PreTrainedModel#init_weights
- Defined in:
- lib/transformers/modeling_utils.rb
#init_weights ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/transformers/modeling_utils.rb', line 219 def init_weights # Prune heads if needed if @config.pruned_heads.any? prune_heads(@config.pruned_heads) end # TODO implement no_init_weights context manager _init_weights = false if _init_weights # Initialize weights apply(method(:_initialize_weights)) # Tie weights should be skipped when not initializing all weights # since from_pretrained(...) calls tie weights anyways tie_weights end end |