TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

[BUG Report]: v0.150.0 breaks multi-input models fit

Open Utanapishtim31 opened this issue 3 years ago • 1 comments

Description

Before TensorFlow.NET v0.150.0 in order to train a multi-input model, I used the method Model.fit(IEnumerable x, NDArray y, ...) with validation_data as a tuple (IEnumerable, NDArray). The enumeration IEnumerable of validation_data contains the several inputs of the model.

With v0.150.0, the tuple is implicitly cast to a ValidationDataPack but this cast keeps only the first NDArray of the validation_data.Item1 enumeration:

public ValidationDataPack((IEnumerable<NDArray>, NDArray) validation_data)
{
    this.val_x = validation_data.Item1.ToArray()[0]; <-- incompatible with multi-input!
    this.val_y = validation_data.Item2;
}

The call to Model.evaluate() in Model.FitInternal() then obviously fails since the validation data format does not match the model inputs anymore.

Reproduction Steps

The problem is obvious.

Known Workarounds

Maybe use the method Model.fit(IDatasetV2 dataset, ..., IDatasetV2 validation_data), but how do I create an IDatasetV2 from a tuple (IEnumerable, NDArray) ?

Configuration and Other Information

TensorFlow.NET 0.150.0 TensorFlow.Keras 0.15.0 Windows 11

Utanapishtim31 avatar Nov 07 '23 09:11 Utanapishtim31

I'm so sorry for this bug, really thank you for this issue. You can use the use v0.110.4 for now, and I will fix it as soon as possible.

Wanglongzhi2001 avatar Nov 07 '23 09:11 Wanglongzhi2001