sdkagent

thinc API reference

101 public APIs from thinc (explosion/thinc) — 22 classes, 41 functions, 38 methods. Signatures extracted by static analysis of the actual source.

Repository: explosion/thinc

KindCount
Classes22
Functions41
Methods38

API list

classthinc.backends._param_server.ParamServer
Serve parameters for a single process.
functhinc.backends.get_current_ops() -> Ops
Get the current backend object.
functhinc.backends.get_ops(name:str, **kwargs) -> Ops
Get a backend object.
classthinc.backends.mps_ops.MPSOps
Ops class for Metal Performance shaders.
functhinc.backends.ops.gaussian_cdf(ops:Ops, X:FloatsXdT) -> FloatsXdT
Gaussian CDF for distribution with mean 0 and stdev 1.
functhinc.backends.ops.gaussian_pdf(ops:Ops, X:FloatsXdT) -> FloatsXdT
Gaussian PDF for distribution with mean 0 and stdev 1.
functhinc.backends.set_current_ops(ops:Ops) -> None
Change the current backend object.
functhinc.backends.set_gpu_allocator(allocator:str) -> None
Route GPU memory allocation via PyTorch or tensorflow.
functhinc.backends.use_pytorch_for_gpu_memory() -> None
Route GPU memory allocation via PyTorch.
functhinc.backends.use_tensorflow_for_gpu_memory() -> None
Route GPU memory allocation via TensorFlow.
methodthinc.config.registry.create(registry_name:str, entry_points:bool=False) -> None
Create a new custom registry.
functhinc.layers.array_getitem.array_getitem(index:Index) -> Model[ArrayTXd, ArrayTXd]
Index into input arrays, and return the subarrays.
functhinc.layers.array_getitem.floats_getitem(index:Index) -> Model[FloatsXd, FloatsXd]
Index into input arrays, and return the subarrays.
functhinc.layers.array_getitem.ints_getitem(index:Index) -> Model[IntsXd, IntsXd]
Index into input arrays, and return the subarrays.
functhinc.layers.bidirectional.bidirectional(l2r:Model[InT, OutT], r2l:Optional[Model[InT, OutT]]=None) -> Model[InT, OutT]
Stitch two RNN models into a bidirectional layer.
functhinc.layers.clone.clone(orig:Model[InT, OutT], n:int) -> Model[InT, OutT]
Construct `n` copies of a layer, with distinct weights.
functhinc.layers.map_list.map_list(layer:Model[InT, OutT]) -> Model[List[InT], List[OutT]]
Create a model that maps a child layer across list inputs.
functhinc.layers.mish.Mish(nO:Optional[int]=None, nI:Optional[int]=None, *init_W:Optional[Callable]=None, *init_b:Optional[Callable]=None, *dropout:Optional[float]=None, *normalize:bool=False) -> Model[InT, OutT]
Dense layer with mish activation.
functhinc.layers.noop.noop(*layers:Model) -> Model[InOutT, InOutT]
Transform a sequences of layers into a null operation.
functhinc.layers.parametricattention.ParametricAttention(nO:Optional[int]=None) -> Model[InT, OutT]
Weight inputs by similarity to a learned vector
functhinc.layers.ragged2list.ragged2list() -> Model[InT, OutT]
Transform sequences from a ragged format into lists.
functhinc.layers.resizable.resizable(layer, resize_layer:Callable) -> Model[InT, OutT]
Container that holds one layer that can change dimensions.
functhinc.layers.with_reshape.with_reshape(layer:Model[OutT, OutT]) -> Model[InT, InT]
Reshape data on the way into and out from a layer.
classthinc.loss.Loss
Base class for classes computing the loss / gradient.
methodthinc.loss.Loss.get_grad(guesses:GuessT, truths:TruthT) -> GradT
Get the gradient of the loss.
classthinc.model.Model
Class for implementing Thinc models and layers.
methodthinc.model.Model.attrs() -> Dict[str, Any]
A dict of the model's attrs.
methodthinc.model.Model.can_from_bytes(bytes_data:bytes, *strict:bool=True) -> bool
Check whether the bytes data is compatible with the model.
methodthinc.model.Model.can_from_dict(msg:Dict, *strict:bool=True) -> bool
Check whether a dictionary is compatible with the model.
methodthinc.model.Model.copy() -> SelfT
Create a copy of the model, its attributes, and its parameters.
methodthinc.model.Model.dim_names() -> Tuple[str, ...]
Get the names of registered dimensions (including unset).
methodthinc.model.Model.finish_update(optimizer:Optimizer) -> None
Update parameters with current gradients.
methodthinc.model.Model.from_bytes(bytes_data:bytes) -> 'Model'
Deserialize the model from a bytes representation.
methodthinc.model.Model.from_disk(path:Union[Path, str]) -> 'Model'
Deserialize the model from disk.
methodthinc.model.Model.get_dim(name:str) -> int
Retrieve the value of a dimension of the given name.
methodthinc.model.Model.get_grad(name:str) -> FloatsXd
Get a gradient from the model.
methodthinc.model.Model.get_param(name:str) -> FloatsXd
Retrieve a weights parameter by name.
methodthinc.model.Model.get_ref(name:str) -> 'Model'
Retrieve the value of a reference of the given name.
methodthinc.model.Model.has_dim(name:str) -> Optional[bool]
Check whether the model has a dimension of a given name.
methodthinc.model.Model.has_grad(name:str) -> bool
Check whether the model has a non-zero gradient for a parameter.
methodthinc.model.Model.has_param(name:str) -> Optional[bool]
Check whether the model has a weights parameter of the given name.
methodthinc.model.Model.has_ref(name:str) -> Optional[bool]
Check whether the model has a reference of a given name.
methodthinc.model.Model.inc_grad(name:str, value:FloatsXd) -> None
Increment the gradient of a parameter by a value.
methodthinc.model.Model.layers() -> List['Model']
A list of child layers of the model.
methodthinc.model.Model.maybe_get_dim(name:str) -> Optional[int]
Retrieve the value of a dimension of the given name, or None.
methodthinc.model.Model.maybe_get_grad(name:str) -> Optional[FloatsXd]
Retrieve a gradient by name, or None.
methodthinc.model.Model.maybe_get_param(name:str) -> Optional[FloatsXd]
Retrieve a weights parameter by name, or None.
methodthinc.model.Model.maybe_get_ref(name:str) -> Optional['Model']
Retrieve the value of a reference if it exists, or None.
methodthinc.model.Model.param_names() -> Tuple[str, ...]
Get the names of registered parameter (including unset).
methodthinc.model.Model.remove_node(node:'Model') -> None
Remove a node from all layers lists, and then update references.
methodthinc.model.Model.replace_node(old:'Model', new:'Model') -> bool
Replace a node anywhere it occurs within the model.
methodthinc.model.Model.set_dim(name:str, value:int, *force:bool=False) -> None
Set a value for a dimension.
methodthinc.model.Model.set_grad(name:str, value:FloatsXd) -> None
Set a gradient value for the model.
methodthinc.model.Model.set_param(name:str, value:Optional[FloatsXd]) -> None
Set a weights parameter's value.
methodthinc.model.Model.set_ref(name:str, value:Optional['Model']) -> None
Set a value for a reference.
methodthinc.model.Model.to_bytes() -> bytes
Serialize the model to a bytes representation.
methodthinc.model.Model.to_cpu() -> None
Transfer the model to CPU.
methodthinc.model.Model.to_dict() -> Dict
Serialize the model to a dict representation.
methodthinc.model.Model.to_disk(path:Union[Path, str]) -> None
Serialize the model to disk.
methodthinc.model.Model.to_gpu(gpu_id:int) -> None
Transfer the model to a given GPU device.
methodthinc.model.Model.walk(*order:str='bfs') -> Iterable['Model']
Iterate out layers of the model.
functhinc.model.deserialize_attr(_:Any, value:Any, name:str, model:Model) -> Any
Deserialize an attribute value (defaults to msgpack).
functhinc.model.serialize_attr(_:Any, value:Any, name:str, model:Model) -> bytes
Serialize an attribute value (defaults to msgpack).
functhinc.model.set_dropout_rate(model:_ModelT, drop:float, attrs=['dropout_rate']) -> _ModelT
Walk over the model's nodes, setting the dropout rate.
functhinc.model.wrap_model_recursive(model:Model, wrapper:Callable[[Model], _ModelT]) -> _ModelT
Recursively wrap a model and its submodules.
functhinc.mypy.get_reducers_type(ctx:FunctionContext) -> Type
Determine a more specific model type for functions that combine models.
functhinc.schedules.compounding(start:float, stop:float, compound:float, *t:float=0.0) -> Iterable[float]
Yield an infinite series of compounding values.
functhinc.schedules.constant(rate:float) -> Iterable[float]
Yield a constant rate.
classthinc.shims.mxnet.MXNetShim
Interface between a MXNet model and a Thinc Model.
classthinc.shims.pytorch.PyTorchShim
Interface between a PyTorch model and a Thinc Model.
functhinc.shims.pytorch.default_serialize_torch_model(model:Any) -> bytes
Serializes the parameters of the wrapped PyTorch model to bytes.
classthinc.shims.pytorch_grad_scaler.PyTorchGradScaler
Gradient scaler for the PyTorch shim.
methodthinc.shims.pytorch_grad_scaler.PyTorchGradScaler.unscale(tensors)
Unscale the given tensors.
classthinc.shims.shim.Shim
Define a basic interface for external models.
classthinc.shims.tensorflow.TensorFlowShim
Interface between a TensorFlow model and a Thinc Model.
classthinc.shims.torchscript.TorchScriptShim
A Thinc shim that wraps a TorchScript module.
classthinc.types.Floats1d
1-dimensional array of floats.
classthinc.types.Floats2d
2-dimensional array of floats
classthinc.types.Floats3d
3-dimensional array of floats
classthinc.types.Floats4d
4-dimensional array of floats.
classthinc.types.Generator
Custom generator type.
classthinc.types.Ints1d
1-dimensional array of ints.
classthinc.types.Ints2d
2-dimensional array of ints.
classthinc.types.Ints3d
3-dimensional array of ints.
classthinc.types.Ints4d
4-dimensional array of ints.
classthinc.types.Padded
A batch of padded sequences, sorted by decreasing length.
classthinc.types.Unserializable
Wrap a value to prevent it from being serialized by msgpack.
classthinc.util.ArrayInfo
Container for info for checking array compatibility.
functhinc.util.assert_mxnet_installed() -> None
Raise an ImportError if MXNet is not installed.
functhinc.util.assert_pytorch_installed() -> None
Raise an ImportError if PyTorch is not installed.
functhinc.util.assert_tensorflow_installed() -> None
Raise an ImportError if TensorFlow is not installed.
functhinc.util.fix_random_seed(seed:int=0) -> None
Set the random seed across random, numpy.random and cupy.random.
functhinc.util.is_cupy_array(obj:Any) -> bool
Check whether an object is a cupy array.
functhinc.util.is_numpy_array(obj:Any) -> bool
Check whether an object is a numpy array.
functhinc.util.is_xp_array(obj:Any) -> bool
Check whether an object is a numpy or cupy array.
functhinc.util.mxnet2xp(mx_tensor:'mx.nd.NDArray', *ops:Optional['Ops']=None) -> ArrayXd
Convert a MXNet tensor to a numpy or cupy tensor.
functhinc.util.prefer_gpu(gpu_id:int=0) -> bool
Use GPU if it's available.
functhinc.util.require_cpu() -> bool
Use CPU through best available backend.
functhinc.util.set_active_gpu(gpu_id:int) -> 'cupy.cuda.Device'
Set the current GPU device for cupy and torch (if available).
functhinc.util.xp2mxnet(xp_tensor:ArrayXd, requires_grad:bool=False) -> 'mx.nd.NDArray'
Convert a numpy or cupy tensor to a MXNet tensor.
functhinc.util.xp2torch(xp_tensor:ArrayXd, requires_grad:bool=False, device:Optional['torch.device']=None) -> 'torch.Tensor'
Convert a numpy or cupy tensor to a PyTorch tensor.

About this data

These signatures were extracted from the public source of explosion/thinc using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries