human
I am working on the file "Seminar3/HW3_Modules.ipynb".
The first task is:
Implement dropout. The idea and implementation is really simple: just multimply the input by $Bernoulli(p)$ mask. 
This is a very cool regularizer. In fact, when you see your net is overfitting try to add more dropout.
While training (self.training == True) it should sample a mask on each iteration (for every batch). When testing this module should implement identity transform i.e. self.output = input.

input:   batch_size x n_feats
output: batch_size x n_feats
Can you write Python program for it?
 Write me a the Python program you requested?
assistant
#Here is the Python program you requested.

class Dropout(Module):
    def __init__(self, p=0.5):
        super(Dropout, self).__init__()
        self.p = p
        self.mask = None
        
    def updateOutput(self, input):
        self.mask = np.random.binomial(1, self.p, size=input.shape)
        self.output = input * self.mask
        return  self.output
    
    def updateGradInput(self, input, gradOutput):
        self.gradInput = gradOutput * self.mask
        return self.gradInput
        
    def __repr__(self):
        return "Dropout"