ai-content-maker/.venv/Lib/site-packages/thinc/layers/logistic.py

26 lines
609 B
Python
Raw Normal View History

2024-05-03 04:18:51 +03:00
from typing import Callable, Tuple
from ..config import registry
from ..model import Model
from ..types import Floats2d
InT = Floats2d
OutT = Floats2d
@registry.layers("Logistic.v1")
def Logistic() -> Model[InT, OutT]:
"""Deprecated in favor of `sigmoid_activation` layer, for more consistent
naming.
"""
return Model("logistic", forward)
def forward(model: Model[InT, OutT], X: InT, is_train: bool) -> Tuple[OutT, Callable]:
Y = model.ops.sigmoid(X, inplace=False)
def backprop(dY: OutT) -> InT:
return dY * model.ops.dsigmoid(Y, inplace=False)
return Y, backprop