1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Import and convert FP16 weights from TensorFlow

This commit is contained in:
Dmitry Kurtaev
2017-09-07 10:18:13 +03:00
parent 1caca2112b
commit ce41a15437
2 changed files with 82 additions and 11 deletions
+18 -2
View File
@@ -76,7 +76,8 @@ static std::string path(const std::string& file)
return findDataFile("dnn/tensorflow/" + file, false);
}
static void runTensorFlowNet(const std::string& prefix)
static void runTensorFlowNet(const std::string& prefix,
double l1 = 1e-5, double lInf = 1e-4)
{
std::string netPath = path(prefix + "_net.pb");
std::string inpPath = path(prefix + "_in.npy");
@@ -89,7 +90,7 @@ static void runTensorFlowNet(const std::string& prefix)
net.setInput(input);
cv::Mat output = net.forward();
normAssert(target, output);
normAssert(target, output, "", l1, lInf);
}
TEST(Test_TensorFlow, single_conv)
@@ -130,4 +131,19 @@ TEST(Test_TensorFlow, deconvolution)
runTensorFlowNet("deconvolution");
}
TEST(Test_TensorFlow, fp16)
{
const float l1 = 1e-3;
const float lInf = 1e-2;
runTensorFlowNet("fp16_single_conv", l1, lInf);
runTensorFlowNet("fp16_deconvolution", l1, lInf);
runTensorFlowNet("fp16_max_pool_odd_same", l1, lInf);
runTensorFlowNet("fp16_padding_valid", l1, lInf);
runTensorFlowNet("fp16_eltwise_add_mul", l1, lInf);
runTensorFlowNet("fp16_max_pool_odd_valid", l1, lInf);
runTensorFlowNet("fp16_pad_and_concat", l1, lInf);
runTensorFlowNet("fp16_max_pool_even", l1, lInf);
runTensorFlowNet("fp16_padding_same", l1, lInf);
}
}