Rate this Page

Class ParameterDictImpl#

Inheritance Relationships#

Base Type#

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> &params)#
inline virtual void reset() override#

reset() is empty for ParameterDict, 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 given stream.

inline Tensor &insert(const std::string &key, const 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