@Namespace(value="torch::nn") @NoOffset @Properties(inherit=torch.class) public class ModuleDictImpl extends ModuleDictImplCloneable
Modules that registers its elements by their keys.
\rst
.. code-block:: cpp
torch::OrderedDictModuleDict instead of a simple map or OrderedDict?
The value a ModuleDict provides over manually calling an ordered map of
modules is that it allows treating the whole container *as a single module*,
such that performing a transformation on the ModuleDict applies to each of
the modules it stores (which are each a registered submodule of the
ModuleDict). For example, calling .to(torch::kCUDA) on a ModuleDict
will move each module in the map to CUDA memory. For example:
\rst
.. code-block:: cpp
torch::OrderedDictModuleDict provides a lightweight container API, such as allowing
iteration over submodules, positional access, adding new modules from a
vector of key-module pairs or an OrderedDict or another ModuleDict after
construction via update.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
ModuleDictImpl() |
ModuleDictImpl(Module pointer)
Downcast constructor.
|
ModuleDictImpl(Pointer p)
Pointer cast constructor.
|
ModuleDictImpl(StringSharedModuleDict modules)
Constructs the
ModuleDict from an OrderedDict. |
ModuleDictImpl(StringSharedModuleVector modules)
Constructs the
ModuleDict from a list of string-Module pairs. |
| Modifier and Type | Method and Description |
|---|---|
StringSharedModuleDictItemVector.Iterator |
begin()
Return an iterator to the start of
ModuleDict. |
void |
clear()
Remove all items from the
ModuleDict. |
Module |
clone() |
Module |
clone(DeviceOptional device)
Special cloning function for
ModuleDict because it does not use
reset(). |
boolean |
contains(BytePointer key)
Check if the centain parameter with the key in the
ModuleDict. |
boolean |
contains(String key) |
boolean |
empty()
Return true if the
ModuleDict is empty, otherwise return false. |
StringSharedModuleDictItemVector.Iterator |
end()
Return an iterator to the end of
ModuleDict. |
Module |
get(BytePointer key)
Attempts to returns the
Module associated with the given key. |
Module |
get(String key) |
StringSharedModuleVector |
items()
Return the items in the
ModuleDict. |
StringVector |
keys()
Return the keys in the
ModuleDict. |
Module |
pop(BytePointer key)
Removes and returns the
Module associated with the given key. |
Module |
pop(String key) |
void |
pretty_print(Pointer stream)
Pretty prints the
ModuleDict into the given stream. |
void |
reset()
reset() is empty for ModuleDict, since it does not have parameters of
its own. |
long |
size()
Return the number of items currently stored in the
ModuleDict. |
void |
update(StringSharedModuleVector modules)
Updated the
ModuleDict with a vector of key-module pairs. |
SharedModuleVector |
values()
Return the values in the
ModuleDict. |
asModule, asModuleapply, apply, apply, apply, apply, apply, apply, apply, buffers, buffers, children, eval, is_serializable, is_training, load, modules, modules, name, named_buffers, named_buffers, named_children, named_modules, named_modules, named_modules, named_parameters, named_parameters, parameters, parameters, register_buffer, register_buffer, register_module, register_module, register_parameter, register_parameter, register_parameter, register_parameter, save, shiftLeft, to, to, to, train, unregister_module, unregister_module, zero_gradaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zeropublic ModuleDictImpl(Pointer p)
Pointer(Pointer).public ModuleDictImpl(Module pointer)
public ModuleDictImpl()
public ModuleDictImpl(@Const @ByRef StringSharedModuleVector modules)
ModuleDict from a list of string-Module pairs.public ModuleDictImpl(@Const @ByRef StringSharedModuleDict modules)
ModuleDict from an OrderedDict.@ByVal public StringSharedModuleVector items()
ModuleDict.@ByVal public StringVector keys()
ModuleDict.@ByVal public SharedModuleVector values()
ModuleDict.@ByVal @Cast(value="torch::nn::ModuleDictImpl::Iterator*") public StringSharedModuleDictItemVector.Iterator begin()
ModuleDict.@ByVal @Cast(value="torch::nn::ModuleDictImpl::Iterator*") public StringSharedModuleDictItemVector.Iterator end()
ModuleDict.@Cast(value="size_t") @NoException(value=true) public long size()
ModuleDict.@Cast(value="bool") @NoException(value=true) public boolean empty()
ModuleDict is empty, otherwise return false.@Cast(value="bool") @NoException(value=true) public boolean contains(@StdString BytePointer key)
ModuleDict.@Cast(value="bool") @NoException(value=true) public boolean contains(@StdString String key)
public void clear()
ModuleDict.@SharedPtr(value="torch::nn::Module") @ByVal public Module clone(@Const @ByRef(nullValue="c10::optional<torch::Device>(c10::nullopt)") DeviceOptional device)
ModuleDict because it does not use
reset().clone in class ModuleDictImplCloneable@SharedPtr(value="torch::nn::Module") @ByVal public Module clone()
clone in class ModuleDictImplCloneablepublic void reset()
reset() is empty for ModuleDict, since it does not have parameters of
its own.reset in class ModuleDictImplCloneablepublic void pretty_print(@Cast(value="std::ostream*") @ByRef Pointer stream)
ModuleDict into the given stream.pretty_print in class Module@SharedPtr(value="torch::nn::Module") @ByVal @Name(value="operator []") public Module get(@StdString BytePointer key)
Module associated with the given key. Throws
an exception if no such key is stored in the ModuleDict. Check
contains(key) before for a non-throwing way of access.@SharedPtr(value="torch::nn::Module") @ByVal @Name(value="operator []") public Module get(@StdString String key)
@SharedPtr(value="torch::nn::Module") @ByVal public Module pop(@StdString BytePointer key)
Module associated with the given key.
Throws an exception if no such key is stored in the ModuleDict.
Check contains(key) before for a non-throwing way of access.@SharedPtr(value="torch::nn::Module") @ByVal public Module pop(@StdString String key)
public void update(@Const @ByRef StringSharedModuleVector modules)
ModuleDict with a vector of key-module pairs.Copyright © 2024. All rights reserved.