pub fn forward(&self, encoder_hidden_states: &Tensor) -> Tensor {
        let output = encoder_hidden_states.apply(&self.dense);
        let output = (self.activation)(&output);
        output.apply(&self.layer_norm)
    }
/// Forward pass through the generator head
///
/// # Arguments
///
/// * `encoder_hidden_states` - Reference to input tensor of shape (*batch size*, *sequence_length*, *hidden_size*).
///
/// # Returns
///
/// * `output` - `Tensor` of shape (*batch size*, *sequence_length*, *embeddings_size*)
///
/// # Example
///
/// ```no_run
/// # use rust_bert::electra::{ElectraConfig, ElectraGeneratorHead};
/// # use tch::{nn, Device, Tensor, no_grad};
/// # use rust_bert::Config;
/// # use std::path::Path;
/// # use tch::kind::Kind::Float;
/// # let config_path = Path::new("path/to/config.json");
/// # let device = Device::Cpu;
/// # let vs = nn::VarStore::new(device);
/// # let config = ElectraConfig::from_file(config_path);
/// # let generator_head = ElectraGeneratorHead::new(&vs.root(), &config);
/// let (batch_size, sequence_length) = (64, 128);
/// let input_tensor = Tensor::rand(
///     &[batch_size, sequence_length, config.hidden_size],
///     (Float, device),
/// );
///
/// let output = no_grad(|| generator_head.forward(&input_tensor));
/// ```
Forward pass through the generator head
Forward pass through the generator head
pub fn forward(&self, encoder_hidden_states: &Tensor) -> Tensor {
        let output = encoder_hidden_states.apply(&self.dense);
        let output = (self.activation)(&output);
        output.apply(&self.layer_norm)
    }
pub fn forward ( & self , encoder_hidden_states : & Tensor ) -> Tensor { let output = encoder_hidden_states . apply ( & self . dense ) ; let output = ( self . activation ) ( & output ) ; output . apply ( & self . layer_norm ) }
Forward pass through the generator head
Forward pass through the generator head
&self
encoder_hidden_states
&Tensor
&self
encoder_hidden_states
&Tensor
example
None
use rust_bert::electra::{electraconfig, electrageneratorhead};
None
use tch::{nn, device, tensor, no_grad};
None
use rust_bert::config;
None
use std::path::path;
None
use tch::kind::kind::float;
None
let config_path = path::new("path/to/config.json");
None
let device = device::cpu;
None
let vs = nn::varstore::new(device);
None
let config = electraconfig::from_file(config_path);
None
let generator_head = electrageneratorhead::new(&vs.root(), &config);
let (batch_size, sequence_length) = (64, 128);
let input_tensor = Tensor::rand(
&[batch_size, sequence_length, config.hidden_size],
(Float, device),
).

let output = no_grad(|| generator_head.forward(&input_tensor));
```
let ( batch_size sequence_length ) = ( 64 128 ) ; let input_tensor = Tensor :: rand ( & [ batch_size sequence_length config . hidden_size ] ( Float device ) ) . let output = no_grad ( || generator_head . forward ( &input_tensor )) ; ` ` `