@@ -427,3 +427,38 @@ TEST(NetworkIntegrationTest, LogTrainingInfoOptionAndSerialization)
427427 std::remove (test_path.c_str ());
428428}
429429
430+ TEST (NetworkIntegrationTest, ShuffleBpttBatchesBehavior)
431+ {
432+ auto options_no_shuffle = NeuralNetworkOptions::create ({ 2 , 2 , 1 })
433+ .with_learning_rate (0.01 )
434+ .with_number_of_epoch (5 )
435+ .with_shuffle_bptt_batches (false )
436+ .with_enable_bptt (true )
437+ .with_bptt_max_ticks (3 )
438+ .build ();
439+
440+ auto options_shuffle = NeuralNetworkOptions::create ({ 2 , 2 , 1 })
441+ .with_learning_rate (0.01 )
442+ .with_number_of_epoch (5 )
443+ .with_shuffle_bptt_batches (true )
444+ .with_enable_bptt (true )
445+ .with_bptt_max_ticks (3 )
446+ .build ();
447+
448+ std::vector<std::vector<double >> inputs = {
449+ {0.1 , 0.2 }, {0.3 , 0.4 }, {0.5 , 0.6 }, {0.7 , 0.8 }, {0.9 , 1.0 }
450+ };
451+ std::vector<std::vector<double >> outputs = {
452+ {0.3 }, {0.7 }, {1.1 }, {1.5 }, {1.9 }
453+ };
454+
455+ NeuralNetwork nn_no_shuffle (options_no_shuffle);
456+ nn_no_shuffle.train (inputs, outputs);
457+
458+ NeuralNetwork nn_shuffle (options_shuffle);
459+ nn_shuffle.train (inputs, outputs);
460+
461+ SUCCEED ();
462+ }
463+
464+
0 commit comments