Skip to content

Instantly share code, notes, and snippets.

@imenurok
imenurok / FRN
Last active November 28, 2019 05:14
Re-implementation: https://arxiv.org/abs/1911.09737
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
class FRN(chainer.Chain):
def __init__(self, in_c):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import random
import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
from chainer import reporter
local PReLU, parent = torch.class('nn.NG','nn.Module')
function PReLU:__init(nOutputPlane)
parent.__init(self)
-- if no argument provided, use shared model (weight is scalar)
self.nOutputPlane = nOutputPlane or 0
self.weight = torch.Tensor(nOutputPlane or 1):fill(0)
self.gradWeight = torch.Tensor(nOutputPlane or 1)
self.buf = torch.Tensor()
self.buf2 = torch.Tensor()