Class ParameterDictImpl¶
Defined in File parameterdict.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Cloneable< ParameterDictImpl >
(Template Class Cloneable)
Class Documentation¶
-
class ParameterDictImpl : public torch::nn::Cloneable<ParameterDictImpl>¶
Public Types
-
using Iterator = OrderedDict<std::string, Tensor>::Iterator¶
-
using ConstIterator = OrderedDict<std::string, Tensor>::ConstIterator¶
Public Functions
-
ParameterDictImpl() = default¶
-
inline explicit ParameterDictImpl(const torch::OrderedDict<std::string, torch::Tensor> ¶ms)¶
-
inline virtual void reset() override¶
reset()
is empty forParameterDict
, since it does not have parameters of its own.
-
inline virtual void pretty_print(std::ostream &stream) const override¶
Pretty prints the
ParameterDict
module into the givenstream
.
-
inline Tensor &insert(std::string key, Tensor param)¶
Insert the parameter along with the key into ParameterDict The parameter is set to be require grad by default.
-
inline Tensor pop(const std::string &key)¶
Remove key from the ParameterDict and return its value, throw exception if the key is not contained.
Please check contains(key) before for a non-throwing access.
-
inline ::std::vector<std::string> keys() const¶
Return the keys in the dict.
-
inline ::std::vector<torch::Tensor> values() const¶
Return the Values in the dict.
-
inline Iterator begin()¶
Return an iterator to the start of ParameterDict.
-
inline ConstIterator begin() const¶
Return a const iterator to the start of ParameterDict.
-
inline Iterator end()¶
Return an iterator to the end of ParameterDict.
-
inline ConstIterator end() const¶
Return a const iterator to the end of ParameterDict.
-
inline size_t size() const noexcept¶
Return the number of items currently stored in the ParameterDict.
-
inline bool empty() const noexcept¶
Return true if the ParameterDict is empty, otherwise return false.
-
template<typename Container>
inline void update(const Container &container)¶ Update the ParameterDict with the key-value pairs from another ParameterDict, overwriting existing key.
-
inline void clear()¶
Remove all parameters in the ParameterDict.
-
inline bool contains(const std::string &key) const noexcept¶
Check if the centain parameter with the key in the ParameterDict.
-
inline const Tensor &get(const std::string &key) const¶
Returns the value associated with the given
key
.Throws an exception if no such key is stored in the
ParameterDict
. Check contains(key) before for a non-throwing way of access
-
inline Tensor &get(const std::string &key)¶
Returns the value associated with the given
key
.Throws an exception if no such key is stored in the
ParameterDict
. Check contains(key) before for a non-throwing way of access
-
inline Tensor &operator[](const std::string &key)¶
Returns the value associated with the given
key
.Throws an exception if no such key is stored in the
ParameterDict
. Check contains(key) before for a non-throwing way of access
-
inline const Tensor &operator[](const std::string &key) const¶
Returns the value associated with the given
key
.Throws an exception if no such key is stored in the
ParameterDict
. Check contains(key) before for a non-throwing way of access
-
using Iterator = OrderedDict<std::string, Tensor>::Iterator¶