Resetting connection in neural networks

username: ati
cooked: <p>Hello<br>
i have a code that it is subclassing nn.module</p>
<pre><code>class Connection(torch.nn.module):
    super().__init__()
    
    def reset_(self) -&gt; None:
   
    """
    Contains resetting logic for the connection.
    """
    super().reset_()
</code></pre>
<p>i don’t know what exactly reset_() does<br>
and i did not find any reset_() function in nn.module source code<br>
So how can i figure out what reset_() exactly does???</p>

username: ptrblck
cooked: <p>As you said, the <code>nn.Module</code> does not have the <code>reset_</code> method implemented.<br>
Where did you find the code?</p>
<p>Also, there are a few issues regardless of the unknown <code>reset_</code> method:</p>
<ul>
<li>
<code>nn.module</code> does not exist and should probably be <code>nn.Module</code>
</li>
<li>the <code>super().__init__()</code> call is outside of the class’ <code>__init__</code> method</li>
<li>the indentation of <code>super().reset_()</code> doesn’t match the <code>def reset</code> indent.</li>
</ul>

username: ati
cooked: <p>Hey …thanks for your response<br>
this is the full code almost:</p>
<pre><code>class AbstractConnection(ABC, Module):

    def __init__(
    self,
    source: Nodes,
    target: Nodes,
    nu: Optional[Union[float, Sequence[float]]] = None,
    reduction: Optional[callable] = None,
    weight_decay: float = 0.0,
    **kwargs
) -&gt; None:
 
    super().__init__()



class Connection(AbstractConnection):

    def __init__(
    self,
    source: Nodes,
    target: Nodes,
    nu: Optional[Union[float, Sequence[float]]] = None,
    reduction: Optional[callable] = None,
    weight_decay: float = 0.0,
    **kwargs
) -&gt; None:


def reset_(self) -&gt; None:
    # language=rst
    """
    Contains resetting logic for the connection.
    """
    super().reset_()</code></pre>

username: ptrblck
cooked: <p>Thanks for code.<br>
I tried to create a small reproducible code snippet and it just seems the base class’ <code>reset_</code> is called, which does nothing, since it’s implemented as a <code>pass</code>:</p>
<pre><code class="lang-python">class AbstractConnection(ABC, nn.Module):
    def __init__(self):
        super(AbstractConnection, self).__init__()
        
    @abstractmethod
    def reset_(self):
        print("base class called")
    
class Connection(AbstractConnection):
    def reset_(self):
        super().reset_()


con = Connection()
con.reset_()
&gt; base class called
</code></pre>
<p>Is this method implemented in another using other options than the <code>super().reset_()</code> call?</p>

username: ati
cooked: <p>thank you <a class="mention" href="/u/ptrblck">@ptrblck</a> very much … Just why we have to write that when we are not using this function reset_() ?<br>
I just saw in another module , that  reset_() has been defined there , but it was not calling by this module…that’s why i don’t know what this functions does…</p>

username: ptrblck
cooked: <p>I’m not familiar with the complete code, but I would assume this function is somewhere implemented and used.<br>
Did another class derive from the class containing the implemented <code>reset_</code> method?</p>

username: ati
cooked: <p>yeah there is another class that is subclassing the class which reset_ method is defined into … but that object is not calling in this class that i sent the code … is that reasonable that we use a method that it has defined in another object and i’m not calling that module/object?</p>

username: ptrblck
cooked: <p>I’m really not sure, what the complete code is doing, so either the author had something in mind and didn’t implement it or some other code parts are using the implemented logic and you are missing them.<br>
Could you post a link to the original implementation, so that we could have a look?</p>

username: ati
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> your questions helped me find my answer …i found this function reset_() in another module that was imported to this module … really very very thank you to all of time u gave me and i appreciate your help :))))))))))))</p>