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

Found that output from forward pass zeros-out during test #526

Open
Niminem opened this issue Sep 15, 2021 · 0 comments
Open

Found that output from forward pass zeros-out during test #526

Niminem opened this issue Sep 15, 2021 · 0 comments

Comments

@Niminem
Copy link
Contributor

Niminem commented Sep 15, 2021

Hello, it seems like the output from the forward pass zeros out with this small example below:

import arraymancer

let ctx = newContext Tensor[float32]
network ctx, Test:
    layers:
        hidden1: Linear(2,3)
        output:  Linear(3,2)
    forward x:
        x.hidden1.relu.output

let model = ctx.init(Test)
var optim = model.optimizerAdam(learningrate=0.001'f32)

var X = ctx.variable(toTensor([[2.1,2.90],[1.001 ,0.908]]).astype(float32))
var y = toTensor([0,1]).astype(float32)

for epoch in 1 .. 10:
    let output = model.forward(X)
    echo output.value
    let loss = sparse_softmax_cross_entropy(output, y)
    echo "Loss is:" & $loss.value
    backprop(loss)
    optim.update()

If you simply add another sample to X and output to y, the forward pass acts normally. Not quite sure why this is.

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

1 participant