thinc の API リファレンス
thinc (explosion/thinc) の公開 API 101 件 —— クラス 22、関数 41、メソッド 38。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: explosion/thinc
| 種別 | 件数 |
|---|---|
| クラス | 22 |
| 関数 | 41 |
| メソッド | 38 |
API 一覧
class
thinc.backends._param_server.ParamServerServe parameters for a single process.
func
thinc.backends.get_current_ops() -> OpsGet the current backend object.
func
thinc.backends.get_ops(name:str, **kwargs) -> OpsGet a backend object.
class
thinc.backends.mps_ops.MPSOpsOps class for Metal Performance shaders.
func
thinc.backends.ops.gaussian_cdf(ops:Ops, X:FloatsXdT) -> FloatsXdTGaussian CDF for distribution with mean 0 and stdev 1.
func
thinc.backends.ops.gaussian_pdf(ops:Ops, X:FloatsXdT) -> FloatsXdTGaussian PDF for distribution with mean 0 and stdev 1.
func
thinc.backends.set_current_ops(ops:Ops) -> NoneChange the current backend object.
func
thinc.backends.set_gpu_allocator(allocator:str) -> NoneRoute GPU memory allocation via PyTorch or tensorflow.
func
thinc.backends.use_pytorch_for_gpu_memory() -> NoneRoute GPU memory allocation via PyTorch.
func
thinc.backends.use_tensorflow_for_gpu_memory() -> NoneRoute GPU memory allocation via TensorFlow.
method
thinc.config.registry.create(registry_name:str, entry_points:bool=False) -> NoneCreate a new custom registry.
func
thinc.layers.array_getitem.array_getitem(index:Index) -> Model[ArrayTXd, ArrayTXd]Index into input arrays, and return the subarrays.
func
thinc.layers.array_getitem.floats_getitem(index:Index) -> Model[FloatsXd, FloatsXd]Index into input arrays, and return the subarrays.
func
thinc.layers.array_getitem.ints_getitem(index:Index) -> Model[IntsXd, IntsXd]Index into input arrays, and return the subarrays.
func
thinc.layers.bidirectional.bidirectional(l2r:Model[InT, OutT], r2l:Optional[Model[InT, OutT]]=None) -> Model[InT, OutT]Stitch two RNN models into a bidirectional layer.
func
thinc.layers.clone.clone(orig:Model[InT, OutT], n:int) -> Model[InT, OutT]Construct `n` copies of a layer, with distinct weights.
func
thinc.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.
func
thinc.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.
func
thinc.layers.noop.noop(*layers:Model) -> Model[InOutT, InOutT]Transform a sequences of layers into a null operation.
func
thinc.layers.parametricattention.ParametricAttention(nO:Optional[int]=None) -> Model[InT, OutT]Weight inputs by similarity to a learned vector
func
thinc.layers.ragged2list.ragged2list() -> Model[InT, OutT]Transform sequences from a ragged format into lists.
func
thinc.layers.resizable.resizable(layer, resize_layer:Callable) -> Model[InT, OutT]Container that holds one layer that can change dimensions.
func
thinc.layers.with_reshape.with_reshape(layer:Model[OutT, OutT]) -> Model[InT, InT]Reshape data on the way into and out from a layer.
class
thinc.loss.LossBase class for classes computing the loss / gradient.
method
thinc.loss.Loss.get_grad(guesses:GuessT, truths:TruthT) -> GradTGet the gradient of the loss.
class
thinc.model.ModelClass for implementing Thinc models and layers.
method
thinc.model.Model.attrs() -> Dict[str, Any]A dict of the model's attrs.
method
thinc.model.Model.can_from_bytes(bytes_data:bytes, *strict:bool=True) -> boolCheck whether the bytes data is compatible with the model.
method
thinc.model.Model.can_from_dict(msg:Dict, *strict:bool=True) -> boolCheck whether a dictionary is compatible with the model.
method
thinc.model.Model.copy() -> SelfTCreate a copy of the model, its attributes, and its parameters.
method
thinc.model.Model.dim_names() -> Tuple[str, ...]Get the names of registered dimensions (including unset).
method
thinc.model.Model.finish_update(optimizer:Optimizer) -> NoneUpdate parameters with current gradients.
method
thinc.model.Model.from_bytes(bytes_data:bytes) -> 'Model'Deserialize the model from a bytes representation.
method
thinc.model.Model.from_disk(path:Union[Path, str]) -> 'Model'Deserialize the model from disk.
method
thinc.model.Model.get_dim(name:str) -> intRetrieve the value of a dimension of the given name.
method
thinc.model.Model.get_grad(name:str) -> FloatsXdGet a gradient from the model.
method
thinc.model.Model.get_param(name:str) -> FloatsXdRetrieve a weights parameter by name.
method
thinc.model.Model.get_ref(name:str) -> 'Model'Retrieve the value of a reference of the given name.
method
thinc.model.Model.has_dim(name:str) -> Optional[bool]Check whether the model has a dimension of a given name.
method
thinc.model.Model.has_grad(name:str) -> boolCheck whether the model has a non-zero gradient for a parameter.
method
thinc.model.Model.has_param(name:str) -> Optional[bool]Check whether the model has a weights parameter of the given name.
method
thinc.model.Model.has_ref(name:str) -> Optional[bool]Check whether the model has a reference of a given name.
method
thinc.model.Model.inc_grad(name:str, value:FloatsXd) -> NoneIncrement the gradient of a parameter by a value.
method
thinc.model.Model.layers() -> List['Model']A list of child layers of the model.
method
thinc.model.Model.maybe_get_dim(name:str) -> Optional[int]Retrieve the value of a dimension of the given name, or None.
method
thinc.model.Model.maybe_get_grad(name:str) -> Optional[FloatsXd]Retrieve a gradient by name, or None.
method
thinc.model.Model.maybe_get_param(name:str) -> Optional[FloatsXd]Retrieve a weights parameter by name, or None.
method
thinc.model.Model.maybe_get_ref(name:str) -> Optional['Model']Retrieve the value of a reference if it exists, or None.
method
thinc.model.Model.param_names() -> Tuple[str, ...]Get the names of registered parameter (including unset).
method
thinc.model.Model.remove_node(node:'Model') -> NoneRemove a node from all layers lists, and then update references.
method
thinc.model.Model.replace_node(old:'Model', new:'Model') -> boolReplace a node anywhere it occurs within the model.
method
thinc.model.Model.set_dim(name:str, value:int, *force:bool=False) -> NoneSet a value for a dimension.
method
thinc.model.Model.set_grad(name:str, value:FloatsXd) -> NoneSet a gradient value for the model.
method
thinc.model.Model.set_param(name:str, value:Optional[FloatsXd]) -> NoneSet a weights parameter's value.
method
thinc.model.Model.set_ref(name:str, value:Optional['Model']) -> NoneSet a value for a reference.
method
thinc.model.Model.to_bytes() -> bytesSerialize the model to a bytes representation.
method
thinc.model.Model.to_cpu() -> NoneTransfer the model to CPU.
method
thinc.model.Model.to_dict() -> DictSerialize the model to a dict representation.
method
thinc.model.Model.to_disk(path:Union[Path, str]) -> NoneSerialize the model to disk.
method
thinc.model.Model.to_gpu(gpu_id:int) -> NoneTransfer the model to a given GPU device.
method
thinc.model.Model.walk(*order:str='bfs') -> Iterable['Model']Iterate out layers of the model.
func
thinc.model.deserialize_attr(_:Any, value:Any, name:str, model:Model) -> AnyDeserialize an attribute value (defaults to msgpack).
func
thinc.model.serialize_attr(_:Any, value:Any, name:str, model:Model) -> bytesSerialize an attribute value (defaults to msgpack).
func
thinc.model.set_dropout_rate(model:_ModelT, drop:float, attrs=['dropout_rate']) -> _ModelTWalk over the model's nodes, setting the dropout rate.
func
thinc.model.wrap_model_recursive(model:Model, wrapper:Callable[[Model], _ModelT]) -> _ModelTRecursively wrap a model and its submodules.
func
thinc.mypy.get_reducers_type(ctx:FunctionContext) -> TypeDetermine a more specific model type for functions that combine models.
func
thinc.schedules.compounding(start:float, stop:float, compound:float, *t:float=0.0) -> Iterable[float]Yield an infinite series of compounding values.
func
thinc.schedules.constant(rate:float) -> Iterable[float]Yield a constant rate.
class
thinc.shims.mxnet.MXNetShimInterface between a MXNet model and a Thinc Model.
class
thinc.shims.pytorch.PyTorchShimInterface between a PyTorch model and a Thinc Model.
func
thinc.shims.pytorch.default_serialize_torch_model(model:Any) -> bytesSerializes the parameters of the wrapped PyTorch model to bytes.
class
thinc.shims.pytorch_grad_scaler.PyTorchGradScalerGradient scaler for the PyTorch shim.
method
thinc.shims.pytorch_grad_scaler.PyTorchGradScaler.unscale(tensors)Unscale the given tensors.
class
thinc.shims.shim.ShimDefine a basic interface for external models.
class
thinc.shims.tensorflow.TensorFlowShimInterface between a TensorFlow model and a Thinc Model.
class
thinc.shims.torchscript.TorchScriptShimA Thinc shim that wraps a TorchScript module.
class
thinc.types.Floats1d1-dimensional array of floats.
class
thinc.types.Floats2d2-dimensional array of floats
class
thinc.types.Floats3d3-dimensional array of floats
class
thinc.types.Floats4d4-dimensional array of floats.
class
thinc.types.GeneratorCustom generator type.
class
thinc.types.Ints1d1-dimensional array of ints.
class
thinc.types.Ints2d2-dimensional array of ints.
class
thinc.types.Ints3d3-dimensional array of ints.
class
thinc.types.Ints4d4-dimensional array of ints.
class
thinc.types.PaddedA batch of padded sequences, sorted by decreasing length.
class
thinc.types.UnserializableWrap a value to prevent it from being serialized by msgpack.
class
thinc.util.ArrayInfoContainer for info for checking array compatibility.
func
thinc.util.assert_mxnet_installed() -> NoneRaise an ImportError if MXNet is not installed.
func
thinc.util.assert_pytorch_installed() -> NoneRaise an ImportError if PyTorch is not installed.
func
thinc.util.assert_tensorflow_installed() -> NoneRaise an ImportError if TensorFlow is not installed.
func
thinc.util.fix_random_seed(seed:int=0) -> NoneSet the random seed across random, numpy.random and cupy.random.
func
thinc.util.is_cupy_array(obj:Any) -> boolCheck whether an object is a cupy array.
func
thinc.util.is_numpy_array(obj:Any) -> boolCheck whether an object is a numpy array.
func
thinc.util.is_xp_array(obj:Any) -> boolCheck whether an object is a numpy or cupy array.
func
thinc.util.mxnet2xp(mx_tensor:'mx.nd.NDArray', *ops:Optional['Ops']=None) -> ArrayXdConvert a MXNet tensor to a numpy or cupy tensor.
func
thinc.util.prefer_gpu(gpu_id:int=0) -> boolUse GPU if it's available.
func
thinc.util.require_cpu() -> boolUse CPU through best available backend.
func
thinc.util.set_active_gpu(gpu_id:int) -> 'cupy.cuda.Device'Set the current GPU device for cupy and torch (if available).
func
thinc.util.xp2mxnet(xp_tensor:ArrayXd, requires_grad:bool=False) -> 'mx.nd.NDArray'Convert a numpy or cupy tensor to a MXNet tensor.
func
thinc.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.
この情報について
掲載しているシグネチャは explosion/thinc の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。