Closed Utanapishtim31 closed 8 months ago
Hello, here is an example which build model use multiple inputs: https://github.com/SciSharp/TensorFlow.NET/blob/9e3654bf9c7c954690d0914558338233d638fcd6/test/TensorFlowNET.Keras.UnitTest/MultiInputModelTest.cs#L13-L61
Using the interface keras.layers indeed solves the problem. Thank you for your help.
Description
I want to create a Keras model with several inputs. When I call
model.Apply(inputs)
where inputs is a Tensors containing several Tensor (i.e. a list-like Tensors object), it fails because it builds for the first time the layers and ends inModel.build(KerasShapesWrapper input_shape)
where _inputshape contains only one shape instead of the many shapes of the inputs.This is caused by
Layer.MaybeBuild(Tensors inputs)
which callsbuild()
with the valuenew KerasShapesWrapper(inputs.shape)
, which creates a KerasShapesWrapper with only the shape of the first Tensor of inputs.Reproduction Steps
Create a neural network with two Dense layers as input, a Concatenate intermediate layer and a final Dense layer as output.
Then call model.Apply(inputs) where inputs is a Tensors object built with two NDArrays as input for each input Dense layer.
Known Workarounds
I have been able to circumvent the problem by keeping the input in an override of Model.Apply() and passing its shape in an override of build() :
Configuration and Other Information
Tensorflow.NET v0.110.4 Tensorflow.Keras v0.11.4 .NET Framework 4.7.2 Windows 11 (Version 10.0.22621)