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 candle-nn::Sequential::new() constructor #2801

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions candle-nn/src/sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ pub struct Sequential {

/// Creates a new empty sequential layer.
pub fn seq() -> Sequential {
Sequential { layers: vec![] }
Sequential::new()
}

impl Sequential {
/// Creates a new empty sequential layer.
pub fn new() -> Self {
Sequential { layers: vec![] }
}

/// The number of sub-layers embedded in this layer.
pub fn len(&self) -> i64 {
self.layers.len() as i64
}

/// Returns true if this layer does not have any sub-layer.
/// Returns true if this layer does not have any sub-layers.
pub fn is_empty(&self) -> bool {
self.layers.is_empty()
}
Expand Down