Bug report: EinsumDense symbolic output shape is incorrect
Background
keras.layers.EinsumDense should produce the same output shape for both eager tensors and symbolic keras.Input tensors when configured identically.
Reproduction
import keras
import numpy as np
layer = keras.layers.EinsumDense(
equation="abc,cd->abd",
output_shape=[None, 64, 32],
bias_axes="d",
)
x1 = np.random.random((5, 32, 128))
out1 = layer(x1)
x2 = keras.Input(shape=(32, 128))
out2 = layer(x2)
print(out1.shape)
print(out2.shape)
Expected result
Both outputs should have the same logical shape for the configured equation, e.g.:
- eager tensor:
(5, 32, 64)
- symbolic tensor:
(None, 32, 64)
Actual result
- eager tensor:
(5, 32, 64)
- symbolic tensor:
(None, None, 64, 32)
This indicates EinsumDense builds/infers the symbolic output shape incorrectly for this valid configuration.
Bug report:
EinsumDensesymbolic output shape is incorrectBackground
keras.layers.EinsumDenseshould produce the same output shape for both eager tensors and symbolickeras.Inputtensors when configured identically.Reproduction
Expected result
Both outputs should have the same logical shape for the configured equation, e.g.:
(5, 32, 64)(None, 32, 64)Actual result
(5, 32, 64)(None, None, 64, 32)This indicates
EinsumDensebuilds/infers the symbolic output shape incorrectly for this valid configuration.