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

[BUG Report]: LayerNormalization BUG #1214

Closed
JustDooooIt opened this issue Nov 9, 2023 · 1 comment
Closed

[BUG Report]: LayerNormalization BUG #1214

JustDooooIt opened this issue Nov 9, 2023 · 1 comment

Comments

@JustDooooIt
Copy link

JustDooooIt commented Nov 9, 2023

Description

Writing keras.layers.LayerNormalization inside the Model class will report an error

Reproduction Steps

[TestMethod]
public void Model1Test()
{
    var model = new TestModel1();
    var tensor = np.random.random((7, 7, 8, 13));
    model.Apply(tensor);
}
public class TestModel1 : Model
{
    ILayer conv2d;
    ILayer norm;

    public TestModel1() : base(new())
    {
        conv2d = tf.keras.layers.Conv2D(16, 3, 1, "same");
        norm = tf.keras.layers.LayerNormalization(-1);
    }

    protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs optional_args = null)
    {
        var x = conv2d.Apply(inputs);
        x = norm.Apply(x);
        return x;
    }
}

Known Workarounds

No response

Configuration and Other Information

No response

@Wanglongzhi2001
Copy link
Collaborator

Wanglongzhi2001 commented Nov 9, 2023

TestModel1 should inherit Layer

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