运行Tensorflow单元测试



有没有办法手动运行Tensorflow单元测试?我想在修改TF源代码时执行健全性检查。

我看到有很多_test.py文件和执行许多测试操作的类,我不知道如何运行它们。应该有一个简单的方法吗?

运行TensorFlow单元测试的最简单方法是使用Bazel,假设您已经从Git:下载了源代码

# All tests (for C++ changes).
$ bazel test //tensorflow/...
# All Python tests (for Python front-end changes).
$ bazel test //tensorflow/python/...
# All tests (with GPU support).
$ bazel test -c opt --config=cuda //tensorflow/...
$ bazel test -c opt --config=cuda //tensorflow/python/...

除了上面的答案之外,您还可以运行单独的测试,而不是完整的包,这可以节省大量的时间。

bazel run //tensorflow/python/kernel_tests:string_split_op_test
bazel run //tensorflow/python:special_math_ops_test

或者你可以转到单独的目录并在那里运行所有的测试

cd python/kernel_tests
bazel run :one_hot_op_test

最新更新