summaryrefslogtreecommitdiff
path: root/candle-transformers/src/models/efficientnet.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2024-12-22 09:18:13 +0100
committerGitHub <noreply@github.com>2024-12-22 09:18:13 +0100
commit62ced44ea94da7062430ed6c21ff17b36f41737d (patch)
treeffcb633955da0d743b013266de9b8b45bd59a1f0 /candle-transformers/src/models/efficientnet.rs
parent5c2f893e5aa21c9f7c82a00407edb6d76db1d06c (diff)
downloadcandle-62ced44ea94da7062430ed6c21ff17b36f41737d.tar.gz
candle-62ced44ea94da7062430ed6c21ff17b36f41737d.tar.bz2
candle-62ced44ea94da7062430ed6c21ff17b36f41737d.zip
Add a Context trait similar to anyhow::Context. (#2676)
* Add a Context trait similar to anyhow::Context. * Switch two unwrap to context.
Diffstat (limited to 'candle-transformers/src/models/efficientnet.rs')
-rw-r--r--candle-transformers/src/models/efficientnet.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/candle-transformers/src/models/efficientnet.rs b/candle-transformers/src/models/efficientnet.rs
index 36754f21..be695460 100644
--- a/candle-transformers/src/models/efficientnet.rs
+++ b/candle-transformers/src/models/efficientnet.rs
@@ -3,7 +3,7 @@
//! See:
//! - ["EfficientBERT: Progressively Searching Multilayer Perceptron Architectures for BERT"](https://arxiv.org/abs/2201.00462)
//!
-use candle::{Result, Tensor, D};
+use candle::{Context, Result, Tensor, D};
use candle_nn as nn;
use nn::{Module, VarBuilder};
@@ -289,7 +289,7 @@ impl EfficientNet {
pub fn new(p: VarBuilder, configs: Vec<MBConvConfig>, nclasses: usize) -> Result<Self> {
let f_p = p.pp("features");
let first_in_c = configs[0].input_channels;
- let last_out_c = configs.last().unwrap().out_channels;
+ let last_out_c = configs.last().context("no last")?.out_channels;
let final_out_c = 4 * last_out_c;
let init_cna = ConvNormActivation::new(f_p.pp(0), 3, first_in_c, 3, 2, 1)?;
let nconfigs = configs.len();