Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeanSquaredError #2

Open
skaae opened this issue Jul 9, 2015 · 5 comments
Open

MeanSquaredError #2

skaae opened this issue Jul 9, 2015 · 5 comments

Comments

@skaae
Copy link
Owner

skaae commented Jul 9, 2015

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
@skaae
Copy link
Owner Author

skaae commented Jul 9, 2015

Der ser ud til at være samme fejl i crossentropy?

@casperkaae
Copy link
Collaborator

Er det ikke mere rigtigt at skalere learningrate med batch_størrelse? Ellers vil cost jo afhænge af batch størrelse når man fx plotter den?

@skaae
Copy link
Owner Author

skaae commented Jul 9, 2015

Er det ikke omvendt. Hvis man ikke skallerer med batch størrelse vil cost afhænge af batchstørrelsen.

Der er en fejl i den Mean squared jeg foreslog:

    def fprop(self, x, t):
        num_batches = x.shape[0]
        cost = 0.5 * (x-t)**2   # samples, num_outputs
        cost = cost.sum()  # sum over output and batches
        return cost / num_batches  # divide by batchsize

@casperkaae
Copy link
Collaborator

Begge dele er fint syntes jeg

Dit forslag giver vel "per sample cost" - Det er også det der bliver gjort i lasagne, så det er fint syntes jeg

@skaae
Copy link
Owner Author

skaae commented Jul 9, 2015

Ok. Vil du copy paste det ind i dit PR? crossentropy er fin udover den er skrevet anderledes.

Du kan evt også cp de forslag som jeg har åbnet issues om? Hvis du er enig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants