MCPcopy Create free account
hub / github.com/evilsocket/cake / sigmoid

Method sigmoid

cake-core/src/backends/cpu/mod.rs:287–298  ·  view source on GitHub ↗
(&self, x: &Tensor)

Source from the content-addressed store, hash-verified

285 }
286
287 fn sigmoid(&self, x: &Tensor) -> Result<Tensor> {
288 if x.dtype() == DType::F32 {
289 let data = x.contiguous()?.flatten_all()?.to_vec1::<f32>()?;
290 let shape = x.dims();
291 let mut out = data;
292 for v in out.iter_mut() {
293 *v = 1.0 / (1.0 + (-*v).exp());
294 }
295 return Tensor::from_vec(out, shape, x.device());
296 }
297 candle_nn::ops::sigmoid(x)
298 }
299
300 fn silu(&self, x: &Tensor) -> Result<Tensor> {
301 if x.dtype() == DType::F32 {

Callers 9

sigmoidFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
test_sigmoid_rangeFunction · 0.45

Calls 3

sigmoidFunction · 0.85
dtypeMethod · 0.80
deviceMethod · 0.45

Tested by 3

test_sigmoid_rangeFunction · 0.36