當前位置: 首頁>>代碼示例>>Python>>正文


Python gen_nn_ops._avg_pool_grad方法代碼示例

本文整理匯總了Python中tensorflow.python.ops.gen_nn_ops._avg_pool_grad方法的典型用法代碼示例。如果您正苦於以下問題:Python gen_nn_ops._avg_pool_grad方法的具體用法?Python gen_nn_ops._avg_pool_grad怎麽用?Python gen_nn_ops._avg_pool_grad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.ops.gen_nn_ops的用法示例。


在下文中一共展示了gen_nn_ops._avg_pool_grad方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _AvgPoolGrad

# 需要導入模塊: from tensorflow.python.ops import gen_nn_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_nn_ops import _avg_pool_grad [as 別名]
def _AvgPoolGrad(op, grad):
  return gen_nn_ops._avg_pool_grad(
      array_ops.shape(op.inputs[0]),
      grad,
      op.get_attr("ksize"),
      op.get_attr("strides"),
      op.get_attr("padding"),
      data_format=op.get_attr("data_format")) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:10,代碼來源:nn_grad.py

示例2: testDirectNotUseOverlapping

# 需要導入模塊: from tensorflow.python.ops import gen_nn_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_nn_ops import _avg_pool_grad [as 別名]
def testDirectNotUseOverlapping(self):
    for num_batches in [1, 3]:
      for row_window_size in [2, 5]:
        for col_window_size in [2, 4]:
          num_rows = row_window_size * 5
          num_cols = col_window_size * 7
          for num_channels in [1, 2]:
            input_shape = (num_batches, num_rows, num_cols, num_channels)
            with self.test_session() as _:
              input_tensor = tf.constant(self._GenerateRandomInputTensor(
                  input_shape).astype(np.float32))
              window_size = [1, row_window_size, col_window_size, 1]
              stride_size = [1, row_window_size, col_window_size, 1]
              padding = "VALID"
              output_tensor = tf.nn.avg_pool(input_tensor, window_size,
                                             stride_size, padding)
              output_data = output_tensor.eval()
              num_elements = 1
              for dim_size in output_data.shape:
                num_elements *= dim_size
              output_backprop = (self._PRNG.rand(num_elements) *
                                 1000).reshape(output_data.shape)
              input_backprop_tensor = gen_nn_ops._avg_pool_grad(
                  input_tensor.get_shape(), output_backprop, window_size,
                  stride_size, padding)
              input_backprop = input_backprop_tensor.eval()
              row_seq = list(range(0, num_rows + 1, row_window_size))
              col_seq = list(range(0, num_cols + 1, col_window_size))
              fap_input_backprop_tensor = gen_nn_ops._fractional_avg_pool_grad(
                  input_tensor.get_shape(),
                  output_backprop,
                  row_seq,
                  col_seq,
                  overlapping=False)
              fap_input_backprop = fap_input_backprop_tensor.eval()
              self.assertShapeEqual(input_backprop, fap_input_backprop_tensor)
              self.assertAllClose(input_backprop, fap_input_backprop) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:39,代碼來源:fractional_avg_pool_op_test.py

示例3: testDirectUseOverlapping

# 需要導入模塊: from tensorflow.python.ops import gen_nn_ops [as 別名]
# 或者: from tensorflow.python.ops.gen_nn_ops import _avg_pool_grad [as 別名]
def testDirectUseOverlapping(self):
    for num_batches in [1, 3]:
      for row_window_size in [2, 5]:
        for col_window_size in [2, 4]:
          num_rows = (row_window_size - 1) * 5 + 1
          num_cols = (col_window_size - 1) * 7 + 1
          for num_channels in [1, 2]:
            input_shape = (num_batches, num_rows, num_cols, num_channels)
            with self.test_session() as _:
              input_tensor = tf.constant(self._GenerateRandomInputTensor(
                  input_shape).astype(np.float32))
              window_size = [1, row_window_size, col_window_size, 1]
              stride_size = [1, row_window_size - 1, col_window_size - 1, 1]
              padding = "VALID"
              output_tensor = tf.nn.avg_pool(input_tensor, window_size,
                                             stride_size, padding)
              output_data = output_tensor.eval()
              num_elements = 1
              for dim_size in output_data.shape:
                num_elements *= dim_size
              output_backprop = (self._PRNG.rand(num_elements) *
                                 1000).reshape(output_data.shape)
              input_backprop_tensor = gen_nn_ops._avg_pool_grad(
                  input_tensor.get_shape(), output_backprop, window_size,
                  stride_size, padding)
              input_backprop = input_backprop_tensor.eval()
              row_seq = list(range(0, num_rows, row_window_size - 1))
              col_seq = list(range(0, num_cols, col_window_size - 1))
              row_seq[-1] += 1
              col_seq[-1] += 1
              fap_input_backprop_tensor = gen_nn_ops._fractional_avg_pool_grad(
                  input_tensor.get_shape(),
                  output_backprop,
                  row_seq,
                  col_seq,
                  overlapping=True)
              fap_input_backprop = fap_input_backprop_tensor.eval()
              self.assertShapeEqual(input_backprop, fap_input_backprop_tensor)
              self.assertAllClose(input_backprop, fap_input_backprop) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:41,代碼來源:fractional_avg_pool_op_test.py


注:本文中的tensorflow.python.ops.gen_nn_ops._avg_pool_grad方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。