有没有办法手动运行 Tensorflow 单元测试?我想在修改 TF 源代码时执行完整性检查。
我看到有许多 _test.py 文件包含执行许多测试操作的类,但我不知道如何运行它们。应该有一个简单的方法?
有没有办法手动运行 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