Browse Source

Add check for dims of x and y in model.fit.

pull/976/head
AsakusaRinne 2 years ago
parent
commit
726b742157
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/TensorFlowNET.Keras/Engine/Model.Fit.cs

+ 5
- 0
src/TensorFlowNET.Keras/Engine/Model.Fit.cs View File

@@ -31,6 +31,11 @@ namespace Tensorflow.Keras.Engine
int workers = 1, int workers = 1,
bool use_multiprocessing = false) bool use_multiprocessing = false)
{ {
if (x.dims[0] != y.dims[0])
{
throw new InvalidArgumentError(
$"The array x and y should have same value at dim 0, but got {x.dims[0]} and {y.dims[0]}");
}
int train_count = Convert.ToInt32(x.dims[0] * (1 - validation_split)); int train_count = Convert.ToInt32(x.dims[0] * (1 - validation_split));
var train_x = x[new Slice(0, train_count)]; var train_x = x[new Slice(0, train_count)];
var train_y = y[new Slice(0, train_count)]; var train_y = y[new Slice(0, train_count)];


Loading…
Cancel
Save