import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras import initializers
# Create a zeros initializer
initializer = tf.keras .initializers .Zeros ( )
# Create a Dense layer with 3 units and the zero initializer for the kernel weights
layer = tf.keras .layers .Dense ( 3 , kernel_initializer= initializer)
# Build the layer to initialize it (requires specifying input shape)
layer.build ( ( None , 4 ) ) # Example input shape, batch size is None (unknown), 4 features
# Print the kernel (weights) of the Dense layer
print ( "Kernel Weights (Layer's weights initialized to Zeros):" )
print ( layer.get_weights ( ) [ 0 ] ) # The weights are the first element in the list returned by get_weights()
# Optionally, you can also print the biases (second element in get_weights())
print ( "Bias Weights (initialized by default):" )
print ( layer.get_weights ( ) [ 1 ] ) # The biases are the second element in the list
aW1wb3J0IHRlbnNvcmZsb3cgYXMgdGYKZnJvbSB0ZW5zb3JmbG93LmtlcmFzIGltcG9ydCBsYXllcnMKZnJvbSB0ZW5zb3JmbG93LmtlcmFzIGltcG9ydCBpbml0aWFsaXplcnMKCiMgQ3JlYXRlIGEgemVyb3MgaW5pdGlhbGl6ZXIKaW5pdGlhbGl6ZXIgPSB0Zi5rZXJhcy5pbml0aWFsaXplcnMuWmVyb3MoKQoKIyBDcmVhdGUgYSBEZW5zZSBsYXllciB3aXRoIDMgdW5pdHMgYW5kIHRoZSB6ZXJvIGluaXRpYWxpemVyIGZvciB0aGUga2VybmVsIHdlaWdodHMKbGF5ZXIgPSB0Zi5rZXJhcy5sYXllcnMuRGVuc2UoMywga2VybmVsX2luaXRpYWxpemVyPWluaXRpYWxpemVyKQoKIyBCdWlsZCB0aGUgbGF5ZXIgdG8gaW5pdGlhbGl6ZSBpdCAocmVxdWlyZXMgc3BlY2lmeWluZyBpbnB1dCBzaGFwZSkKbGF5ZXIuYnVpbGQoKE5vbmUsIDQpKSAgIyBFeGFtcGxlIGlucHV0IHNoYXBlLCBiYXRjaCBzaXplIGlzIE5vbmUgKHVua25vd24pLCA0IGZlYXR1cmVzCgojIFByaW50IHRoZSBrZXJuZWwgKHdlaWdodHMpI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