codecamp

TensorFlow 测试

单元测试

TensorFlow 提供了一个方便的类,继承 unittest.TestCase,可以添加与 TensorFlow 测试相关的方法。如下述的例子:tf.

import tensorflow as tf

class SquareTest(tf.test.TestCase):

  def testSquare(self):
    with self.test_session():
      x = tf.square([2, 3])
      self.assertAllEqual(x.eval(), [4, 9])

if __name__ == '__main__':
  tf.test.main()

tf.test.TestCase 继承了 unittest.TestCase,但添加了一些额外的方法,我们将很快证明这些方法。

  • tf.test.main
  • tf.test.TestCase
  • tf.test.test_src_dir_path

TensorFlow 实用程序

  • tf.test.assert_equal_graph_def
  • tf.test.get_temp_dir
  • tf.test.is_built_with_cuda
  • tf.test.is_gpu_available
  • tf.test.gpu_device_name

TensorFlow 梯度检测

tf.test.compute_gradient 和 tf.test.compute_gradient_error 对图进行数值微分,以便与已注册的分析梯度进行比较。

TensorFlow调试器
TensorFlow Training函数(contrib)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }