Giter Site home page Giter Site logo

summerschool's Issues

TanhActivationLayer

Tanh har ikke den rigtige gradient. Eller den er i hverttilfælde ustabil

Her er en bedre implementering:

class TanhActivationLayer():
    def __str__(self):
        return "Tanh()"

    def fprop(self, x, train=True):
        self.a = np.tanh(x)
        return self.a

    def bprop(self, delta_in):
        return (1-self.a**2)*delta_in

    def update_params(self, lr):
        pass

SoftPlus

I softplus får jeg:

math

Jeg ved ikke om det kan simplificeres yderligere?

Jeg foreslår vi implementerer det som:

class SoftplusActivationLayer():
    def __str__(self):
        return "Softplus()"

    def fprop(self, x, train=True):
        self.g = np.exp(x) + 1
        self.a = np.log(g)
        return self.a

    def bprop(self, delta_in):
        return delta_in * 1-g**(-1)

    def update_params(self, lr):
        pass

MeanSquaredError

Jeg tror der er en fejl i MeanSquaredError.

  1. Skal bprop ikke være:
delta_out = y-t
delta_out /= y.shape[0]  # divide by num_batches
  1. Jeg synes fprop er lidt svær at læse p.g.a. np.mean. Jeg er i tvivl om det korrekte er at normalisere med num_batches eller num_bathces * num_outputs??
    Jeg foreslår:
    def fprop(self, x, t):
        num_batches = x.shape[0]
        cost = 0.5 * (x-t)**2   # samples, num_outputs
        cost = cost.sum(axis=-1)  # sum out outputs
        return cost / num_batches

Orginal

class MeanSquaredLoss():
    def __str__(self): 
        return "MeanSquaredLoss()"

    def fprop(self, x, t):
        num_batches = x.shape[0]
        cost = 0.5 * (x-t)**2 / num_batches
        return np.mean(np.sum(cost, axis=-1))

    def bprop(self, y, t):
        delta_out = y-t
        return delta_out

    def update_params(self):
        pass

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.