Specifying a weight initialiser returns an error: Could not interpret initializer identifier: 0
Asked Answered
S

0

0

Why am I getting this error?

In one of the Dense layers I want to specify the HE Uniform weight initializer, like so:

Dense(64, input_shape=input_shape, kernel_initializer=tf.keras.initializers.he_uniform())

And I get an error: ValueError: Could not interpret initializer identifier: 0

When instead I specify it differently , like this:

kernel_initializer=tf.keras.initializers.HeUniform()

I get a different error: module 'tensorflow_core.keras.initializers' has no attribute 'HeUniform'

I am using the following imports:

import tensorflow as tf
import tensorflow.keras as keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

What is wrong? And btw what is the difference between HeUniform() and he_uniform()?

Thanks

Smokejumper answered 11/11, 2021 at 11:51 Comment(4)
HeUniform() and he_uniform() are the same. I tried to reproduce your error but it worked fine for me. What is the value of the input_shape parameter?Sherl
The input_shape is train_data[0].shape which in my case is (4,)Smokejumper
I cannot reproduce this with your code. Are you sure you provided the line causing the error? Also which tensorflow version are you using? (output of tf.__version__)Selfimprovement
My bad, the error was being caused by something elseSmokejumper

© 2022 - 2025 — McMap. All rights reserved.