| 2371 | } |
| 2372 | |
| 2373 | int testValid_WithMSE() { |
| 2374 | Specification::Model spec; |
| 2375 | Result res; |
| 2376 | TensorAttributes tensorAttributesIn = { "InTensor", 3 }; |
| 2377 | TensorAttributes tensorAttributesOut = { "OutTensor", 1 }; |
| 2378 | |
| 2379 | (void)buildBasicNeuralNetworkModel(spec, true, &tensorAttributesIn, &tensorAttributesOut, 1024); |
| 2380 | spec.set_specificationversion(MLMODEL_SPECIFICATION_VERSION_IOS13); |
| 2381 | auto neuralNet = spec.mutable_neuralnetwork(); |
| 2382 | |
| 2383 | std::string targetName = "mse_target"; |
| 2384 | addMeanSquareError(spec, neuralNet, "mean_square_error", "OutTensor", targetName.c_str()); |
| 2385 | |
| 2386 | spec.mutable_description()->clear_traininginput(); |
| 2387 | |
| 2388 | for (auto feature : spec.description().input()) { |
| 2389 | auto trainingInput = spec.mutable_description()->mutable_traininginput()->Add(); |
| 2390 | trainingInput->CopyFrom(feature); |
| 2391 | } |
| 2392 | |
| 2393 | auto trainingInput = spec.mutable_description()->mutable_traininginput()->Add(); |
| 2394 | std::string target = spec.neuralnetwork().updateparams().losslayers(0).meansquarederrorlosslayer().target(); |
| 2395 | trainingInput->set_name(targetName); |
| 2396 | auto trainingInputTensorShape = trainingInput->mutable_type()->mutable_multiarraytype(); |
| 2397 | trainingInputTensorShape->set_datatype(Specification::ArrayFeatureType_ArrayDataType_DOUBLE); |
| 2398 | trainingInputTensorShape->add_shape(1); |
| 2399 | |
| 2400 | addLearningRate(neuralNet, Specification::Optimizer::kSgdOptimizer, 0.7f, 0.0f, 1.0f); |
| 2401 | addMiniBatchSize(neuralNet, Specification::Optimizer::kSgdOptimizer, 10, 5, 100, std::set<int64_t>()); |
| 2402 | addEpochs(neuralNet, 100, 1, 100, std::set<int64_t>()); |
| 2403 | addShuffleAndSeed(neuralNet, 2019, 0, 2019, std::set<int64_t>()); |
| 2404 | |
| 2405 | res = Model::validate(spec); |
| 2406 | ML_ASSERT_GOOD(res); |
| 2407 | |
| 2408 | return 0; |
| 2409 | } |
| 2410 | |
| 2411 | int testValid_Pipeline() { |
| 2412 | Specification::Model spec; |
nothing calls this directly
no test coverage detected