Skip to content

Adagrad optimizer and test - #20

Open
mawenyuan1997 wants to merge 2 commits into
stevenygd:masterfrom
mawenyuan1997:AdagradOptimizer
Open

Adagrad optimizer and test#20
mawenyuan1997 wants to merge 2 commits into
stevenygd:masterfrom
mawenyuan1997:AdagradOptimizer

Conversation

@mawenyuan1997

Copy link
Copy Markdown
Contributor

No description provided.

end

# build the net
layers = Layer[InputLayer((1,2)), DenseLayer(2), Sigmoid(), DenseLayer(1), Sigmoid()]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain for a little bit why you need the last two layers? (i.e. DenseLayer and Sigmoid?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are the output layer of the XOR perceptron.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I think the last layer might not be quite necessary, but as long as it works.

Comment thread src/optimizers/Adagrad.jl
cache = []
for i = 1:length(net.layers)
layer = net.layers[i]
param = getParam(layer)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that there might be a better way to check whether a layer is a learnable layer. Maybe you could experiment on using type information?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried "typeof(layer) <: LearnableLayer" but it doesn't work. I am not sure if those layers, like DenseLayer, are declared as LearnableLayer.

Comment thread src/optimizers/Adagrad.jl Outdated
g = grad[j]
@assert size(c) == size(p) && size(c) == size(g)
c = c + g.^2
# not sure

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this comment referring to? Not sure about the smoothing epsilons?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I was not sure about declaring iteration as a parameter and later I forgot to delete the comment. Resolved.

Comment thread src/optimizers/Adagrad.jl Outdated
@assert size(c) == size(p) && size(c) == size(g)
c = c + g.^2
# not sure
p = p - this.base_lr(this.iter) * g ./ (sqrt(c) + 1e-10)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could put this 1e-10 epsilon as a parameter for this layer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

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

Successfully merging this pull request may close these issues.

2 participants