core/network.py
def forward_with_activations(self, coords, retain_grad=False):
        '''Returns not only model output, but also intermediate activations.
        Only used for visualizing activations later!'''
        activations = OrderedDict()

        activation_count = 0
        x = coords.clone().detach().requires_grad_(True)
        activations['input'] = x
        for i, layer in enumerate(self.net):
            if isinstance(layer, SineLayer) or isinstance(layer, ReLuLayer):
                x, intermed = layer.forward_with_intermediate(x)

                if retain_grad:
                    x.retain_grad()
                    intermed.retain_grad()

                activations['_'.join((str(layer.__class__), "%d" % activation_count))] = intermed
                activation_count += 1
            else:
                x = layer(x)

                if retain_grad:
                    x.retain_grad()

            activations['_'.join((str(layer.__class__), "%d" % activation_count))] = x
            activation_count += 1

        return activations
Returns not only model output, but also intermediate activations.
        Only used for visualizing activations later!
Returns not only model output, but also intermediate activations.
Only used for visualizing activations later!
Returns not only model output but also intermediate activations . Only used for visualizing activations later!
def forward_with_activations(self, coords, retain_grad=False):
        activations = OrderedDict()
        activation_count = 0
        x = coords.clone().detach().requires_grad_(True)
        activations['input'] = x
        for i, layer in enumerate(self.net):
            if isinstance(layer, SineLayer) or isinstance(layer, ReLuLayer):
                x, intermed = layer.forward_with_intermediate(x)
                if retain_grad:
                    x.retain_grad()
                    intermed.retain_grad()
                activations['_'.join((str(layer.__class__), "%d" % activation_count))] = intermed
                activation_count += 1
            else:
                x = layer(x)
                if retain_grad:
                    x.retain_grad()
            activations['_'.join((str(layer.__class__), "%d" % activation_count))] = x
            activation_count += 1
        return activations
def forward_with_activations ( self , coords , retain_grad = False ) : activations = OrderedDict ( ) activation_count = 0 x = coords . clone ( ) . detach ( ) . requires_grad_ ( True ) activations [ 'input' ] = x for i , layer in enumerate ( self . net ) : if isinstance ( layer , SineLayer ) or isinstance ( layer , ReLuLayer ) : x , intermed = layer . forward_with_intermediate ( x ) if retain_grad : x . retain_grad ( ) intermed . retain_grad ( ) activations [ '_' . join ( ( str ( layer . __class__ ) , "%d" % activation_count ) ) ] = intermed activation_count += 1 else : x = layer ( x ) if retain_grad : x . retain_grad ( ) activations [ '_' . join ( ( str ( layer . __class__ ) , "%d" % activation_count ) ) ] = x activation_count += 1 return activations
Returns not only model output, but also intermediate activations.
Returns not only model output but also intermediate activations .
'''Returns not only model output, but also intermediate activations.
        Only used for visualizing activations later!'''
self
coords
retain_grad