Sequential ( l, l ) > for idx, m in enumerate ( net. The submodule referenced by target Return typeĬasts all floating point parameters and buffers to half datatype. Target ( str) – The fully-qualified string name of the submodule If some submodule exists, get_submodule should always be Named_modules achieves the same result, but it is O(N) in The runtime of get_submodule is bounded by the degree We have the conv submodule, we would call Would call get_submodule("net_b.linear"). To check whether or not we have the linear submodule, we Submodule net_b, which itself has two submodules net_cĪnd linear. (linear): Linear(in_features=100, out_features=200, bias=True) Return the submodule given by target if it exists, otherwise throw an error.įor example, let’s say you have an nn.Module A that Path or resolves to something that is not an The Parameter referenced by target Return type Target ( str) – The fully-qualified string name of the Parameter Return the parameter given by target if it exists, otherwise throw an error. ReturnsĪny extra state to store in the module’s state_dict Return type We only provide provide backwards compatibility guaranteesįor serializing Tensors other objects may break backwards compatibility if Note that extra state should be picklable to ensure working serialization This function is called when building the Implement this and a corresponding set_extra_state() for your module
Return any extra state to include in the module’s state_dict. Path or resolves to something that is not a The buffer referenced by target Return typeĪttributeError – If the target string references an invalid Target ( str) – The fully-qualified string name of the buffer
See the docstring for get_submodule for a more detailedĮxplanation of this method’s functionality as well as how to Return the buffer given by target if it exists, otherwise throw an error. Registered hooks while the latter silently ignores them. Instead of this since the former takes care of running the This function, one should call the Module instance afterwards