Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hardsigmoid formula and fix WGAN doc + default lr #2706

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/burn-tensor/src/tensor/activation/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ pub fn sigmoid<const D: usize, B: Backend>(tensor: Tensor<B, D>) -> Tensor<B, D>
}

/// Applies the hard sigmoid function
///
/// `hard_sigmoid(x) = max(0, min(1, alpha * x + beta))`
pub fn hard_sigmoid<const D: usize, B: Backend>(
tensor: Tensor<B, D>,
alpha: f64,
Expand Down
2 changes: 1 addition & 1 deletion examples/wgan/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct ModelConfig {
}

impl ModelConfig {
/// "init" is used to create other objects, while "new" is usally used to create itself.
/// Initialize the generator and discriminator models based on the config.
pub fn init<B: Backend>(&self, device: &B::Device) -> (Generator<B>, Discriminator<B>) {
// Construct the initialized generator
let layer1 = LayerBlock::new(self.latent_dim, 128, device);
Expand Down
2 changes: 1 addition & 1 deletion examples/wgan/src/training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct TrainingConfig {
pub num_workers: usize,
#[config(default = 5)]
pub seed: u64,
#[config(default = 5e-5)]
#[config(default = 3e-4)]
pub lr: f64,

/// Number of training steps for discriminator before generator is trained per iteration
Expand Down
Loading