Merge changes from github.
Change: 144396000
This commit is contained in:
parent
bb4d61d06a
commit
769496bb0d
@ -177,7 +177,8 @@ def _fused_batch_norm(
|
||||
Lower `decay` value (recommend trying `decay`=0.9) if model experiences
|
||||
reasonably good training performance but poor validation and/or test
|
||||
performance.
|
||||
center: If True, subtract `beta`. If False, `beta` is ignored.
|
||||
center: If True, add offset of `beta` to normalized tensor. If False,
|
||||
`beta` is ignored.
|
||||
scale: If True, multiply by `gamma`. If False, `gamma` is
|
||||
not used. When the next layer is linear (also e.g. `nn.relu`), this can be
|
||||
disabled since the scaling can be done by the next layer.
|
||||
@ -408,7 +409,8 @@ def batch_norm(
|
||||
Lower `decay` value (recommend trying `decay`=0.9) if model experiences
|
||||
reasonably good training performance but poor validation and/or test
|
||||
performance. Try zero_debias_moving_mean=True for improved stability.
|
||||
center: If True, subtract `beta`. If False, `beta` is ignored.
|
||||
center: If True, add offset of `beta` to normalized tensor. If False, `beta`
|
||||
is ignored.
|
||||
scale: If True, multiply by `gamma`. If False, `gamma` is
|
||||
not used. When the next layer is linear (also e.g. `nn.relu`), this can be
|
||||
disabled since the scaling can be done by the next layer.
|
||||
@ -1444,7 +1446,8 @@ def layer_norm(inputs,
|
||||
Args:
|
||||
inputs: a tensor with 2 or more dimensions. The normalization
|
||||
occurs over all but the first dimension.
|
||||
center: If True, subtract `beta`. If False, `beta` is ignored.
|
||||
center: If True, add offset of `beta` to normalized tensor. If False, `beta`
|
||||
is ignored.
|
||||
scale: If True, multiply by `gamma`. If False, `gamma` is
|
||||
not used. When the next layer is linear (also e.g. `nn.relu`), this can be
|
||||
disabled since the scaling can be done by the next layer.
|
||||
|
@ -334,8 +334,8 @@ class DNNComposableModel(_ComposableModel):
|
||||
|
||||
def _add_hidden_layer_summary(self, value, tag):
|
||||
# TODO(zakaria): Move this code to tf.learn and add test.
|
||||
summary.scalar("%s:fraction_of_zero_values" % tag, nn.zero_fraction(value))
|
||||
summary.histogram("%s:activation" % tag, value)
|
||||
summary.scalar("%s/fraction_of_zero_values" % tag, nn.zero_fraction(value))
|
||||
summary.histogram("%s/activation" % tag, value)
|
||||
|
||||
def build_model(self, features, feature_columns, is_training):
|
||||
"""See base class."""
|
||||
|
@ -87,9 +87,9 @@ def _linear_learning_rate(num_linear_feature_columns):
|
||||
|
||||
|
||||
def _add_hidden_layer_summary(value, tag):
|
||||
logging_ops.scalar_summary("%s:fraction_of_zero_values" % tag,
|
||||
logging_ops.scalar_summary("%s/fraction_of_zero_values" % tag,
|
||||
nn.zero_fraction(value))
|
||||
logging_ops.histogram_summary("%s:activation" % tag, value)
|
||||
logging_ops.histogram_summary("%s/activation" % tag, value)
|
||||
|
||||
|
||||
def _get_embedding_variable(column, collection_key, input_layer_scope):
|
||||
|
@ -20,7 +20,6 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
# pylint: disable=wildcard-import
|
||||
from tensorflow.contrib.learn.python.learn.ops.array_ops import *
|
||||
from tensorflow.contrib.learn.python.learn.ops.embeddings_ops import *
|
||||
from tensorflow.contrib.learn.python.learn.ops.losses_ops import *
|
||||
from tensorflow.contrib.learn.python.learn.ops.seq2seq_ops import *
|
||||
|
@ -1,52 +0,0 @@
|
||||
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
|
||||
"""TensorFlow ops for array / tensor manipulation."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from tensorflow.contrib.framework import deprecated
|
||||
from tensorflow.python.framework import dtypes
|
||||
from tensorflow.python.framework import ops
|
||||
from tensorflow.python.ops import array_ops as array_ops_
|
||||
from tensorflow.python.ops import math_ops
|
||||
|
||||
|
||||
@deprecated('2016-12-01', 'Use `tf.one_hot` instead.')
|
||||
def one_hot_matrix(tensor_in, num_classes, on_value=1.0, off_value=0.0,
|
||||
name=None):
|
||||
"""Encodes indices from given tensor as one-hot tensor.
|
||||
|
||||
TODO(ilblackdragon): Ideally implementation should be
|
||||
part of TensorFlow with Eigen-native operation.
|
||||
|
||||
Args:
|
||||
tensor_in: Input `Tensor` of shape [N1, N2].
|
||||
num_classes: Number of classes to expand index into.
|
||||
on_value: `Tensor` or float, value to fill-in given index.
|
||||
off_value: `Tensor` or float, value to fill-in everything else.
|
||||
name: Name of the op.
|
||||
Returns:
|
||||
`Tensor` of shape `[N1, N2, num_classes]` with 1.0 for each id in original
|
||||
tensor.
|
||||
"""
|
||||
with ops.name_scope(
|
||||
name, 'one_hot_matrix',
|
||||
[tensor_in, num_classes, on_value, off_value]) as name_scope:
|
||||
return array_ops_.one_hot(
|
||||
math_ops.cast(tensor_in, dtypes.int64), num_classes, on_value,
|
||||
off_value, name=name_scope)
|
@ -32,8 +32,8 @@ from tensorflow.contrib.learn.python.learn import ops
|
||||
from tensorflow.python.framework import constant_op
|
||||
from tensorflow.python.framework import dtypes
|
||||
from tensorflow.python.framework import random_seed
|
||||
from tensorflow.python.ops import array_ops
|
||||
from tensorflow.python.ops import variables
|
||||
from tensorflow.python.ops import array_ops
|
||||
from tensorflow.python.platform import test
|
||||
|
||||
|
||||
@ -80,15 +80,6 @@ class OpsTest(test.TestCase):
|
||||
self.assertEqual(emb1.shape, emb2.shape)
|
||||
self.assertAllEqual(np.transpose(emb2, axes=[1, 0, 2]), emb1)
|
||||
|
||||
def test_one_hot_matrix(self):
|
||||
with self.test_session() as sess:
|
||||
tensor_in = array_ops.placeholder(dtypes.int64, [10, 2])
|
||||
one_hot_tensor = ops.one_hot_matrix(tensor_in, 3)
|
||||
res = sess.run(ops.one_hot_matrix([[0, 1], [2, 1]], 3))
|
||||
self.assertAllEqual(one_hot_tensor.get_shape(), [10, 2, 3])
|
||||
self.assertAllEqual(res, [[[1.0, 0, 0], [0, 1.0, 0]],
|
||||
[[0, 0, 1.0], [0, 1.0, 0]]])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test.main()
|
||||
|
@ -20,10 +20,9 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from tensorflow.contrib import rnn
|
||||
from tensorflow.contrib.learn.python.learn.ops import array_ops
|
||||
from tensorflow.python.framework import dtypes
|
||||
from tensorflow.python.framework import ops
|
||||
from tensorflow.python.ops import array_ops as array_ops_
|
||||
from tensorflow.python.ops import array_ops
|
||||
from tensorflow.python.ops import math_ops
|
||||
from tensorflow.python.ops import nn
|
||||
from tensorflow.python.ops import variable_scope as vs
|
||||
@ -55,7 +54,7 @@ def sequence_classifier(decoding, labels, sampling_decoding=None, name=None):
|
||||
predictions.append(nn.softmax(pred))
|
||||
xent = math_ops.add_n(xent_list, name="sequence_loss/xent")
|
||||
loss = math_ops.reduce_sum(xent, name="sequence_loss")
|
||||
return array_ops_.stack(predictions, axis=1), loss
|
||||
return array_ops.stack(predictions, axis=1), loss
|
||||
|
||||
|
||||
def seq2seq_inputs(x, y, input_length, output_length, sentinel=None, name=None):
|
||||
@ -75,13 +74,13 @@ def seq2seq_inputs(x, y, input_length, output_length, sentinel=None, name=None):
|
||||
Encoder input from x, and decoder inputs and outputs from y.
|
||||
"""
|
||||
with ops.name_scope(name, "seq2seq_inputs", [x, y]):
|
||||
in_x = array_ops_.unstack(x, axis=1)
|
||||
y = array_ops_.unstack(y, axis=1)
|
||||
in_x = array_ops.unstack(x, axis=1)
|
||||
y = array_ops.unstack(y, axis=1)
|
||||
if not sentinel:
|
||||
# Set to zeros of shape of y[0], using x for batch size.
|
||||
sentinel_shape = array_ops_.stack(
|
||||
[array_ops_.shape(x)[0], y[0].get_shape()[1]])
|
||||
sentinel = array_ops_.zeros(sentinel_shape)
|
||||
sentinel_shape = array_ops.stack(
|
||||
[array_ops.shape(x)[0], y[0].get_shape()[1]])
|
||||
sentinel = array_ops.zeros(sentinel_shape)
|
||||
sentinel.set_shape(y[0].get_shape())
|
||||
in_y = [sentinel] + y
|
||||
out_y = y + [sentinel]
|
||||
|
@ -262,6 +262,7 @@ cc_library(
|
||||
"platform/subprocess.h",
|
||||
"platform/thread_annotations.h",
|
||||
"platform/types.h",
|
||||
"platform/windows/cpu_info.h",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
@ -20,18 +20,31 @@ namespace tensorflow {
|
||||
void FloatToBFloat16(const float* src, bfloat16* dst, int64 size) {
|
||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(src);
|
||||
uint16_t* q = reinterpret_cast<uint16_t*>(dst);
|
||||
for (; size; p += 2, q++, size--) {
|
||||
*q = p[1];
|
||||
}
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
for (; size != 0; p += 2, q++, size--) {
|
||||
*q = p[0];
|
||||
}
|
||||
#else
|
||||
for (; size != 0; p += 2, q++, size--) {
|
||||
*q = p[1];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BFloat16ToFloat(const bfloat16* src, float* dst, int64 size) {
|
||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(src);
|
||||
uint16_t* q = reinterpret_cast<uint16_t*>(dst);
|
||||
for (; size; p++, q += 2, size--) {
|
||||
q[0] = 0;
|
||||
q[1] = *p;
|
||||
}
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
for (; size != 0; p++, q += 2, size--) {
|
||||
q[0] = *p;
|
||||
q[1] = 0;
|
||||
}
|
||||
#else
|
||||
for (; size != 0; p++, q += 2, size--) {
|
||||
q[0] = 0;
|
||||
q[1] = *p;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace tensorflow
|
||||
|
@ -19,6 +19,10 @@ limitations under the License.
|
||||
#include "tensorflow/core/framework/numeric_types.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include "tensorflow/core/platform/windows/cpu_info.h"
|
||||
#endif
|
||||
|
||||
// Compact 16-bit encoding of floating point numbers. This representation uses
|
||||
// 1 bit for the sign, 8 bits for the exponent and 7 bits for the mantissa. It
|
||||
// is assumed that floats are in IEEE 754 format so the representation is just
|
||||
|
@ -96,11 +96,16 @@ struct scalar_cast_op<::tensorflow::bfloat16, float> {
|
||||
typedef float result_type;
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator()(
|
||||
const ::tensorflow::bfloat16& a) const {
|
||||
static_assert(::tensorflow::port::kLittleEndian, "");
|
||||
float ret;
|
||||
uint16_t* p = reinterpret_cast<uint16_t*>(&ret);
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
p[0] = a.value;
|
||||
p[1] = 0;
|
||||
#else
|
||||
static_assert(::tensorflow::port::kLittleEndian, "Not a little endian system!");
|
||||
p[0] = 0;
|
||||
p[1] = a.value;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
@ -116,9 +121,14 @@ struct scalar_cast_op<float, ::tensorflow::bfloat16> {
|
||||
typedef ::tensorflow::bfloat16 result_type;
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ::tensorflow::bfloat16 operator()(
|
||||
const float a) const {
|
||||
static_assert(::tensorflow::port::kLittleEndian, "");
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(&a);
|
||||
return ::tensorflow::bfloat16(p[0]);
|
||||
#else
|
||||
static_assert(::tensorflow::port::kLittleEndian, "Not a little endian system!");
|
||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(&a);
|
||||
return ::tensorflow::bfloat16(p[1]);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -258,7 +258,11 @@ static const int kNumOperands = (sizeof(Packet) / sizeof(float));
|
||||
ALWAYS_INLINE float ConvertBfloat16ToFloat(const bfloat16* src) {
|
||||
float out = 0;
|
||||
auto tmp = reinterpret_cast<bfloat16*>(&out);
|
||||
tmp[1] = *src;
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
tmp[0] = *src;
|
||||
#else
|
||||
tmp[1] = *src;
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include "tensorflow/core/platform/windows/cpu_info.h"
|
||||
#include "tensorflow/core/platform/windows/intrinsics_port.h"
|
||||
#endif
|
||||
|
||||
@ -30,8 +31,12 @@ namespace internal {
|
||||
// in the lower 16-bits of input
|
||||
template <typename Packet>
|
||||
EIGEN_DEVICE_FUNC inline Packet pexpand_bf16_l(const Packet& from) {
|
||||
tensorflow::uint32 tmp =
|
||||
(reinterpret_cast<const tensorflow::uint32&>(from) << 16) & 0xffff0000;
|
||||
tensorflow::uint32 tmp;
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
tmp = (reinterpret_cast<const tensorflow::uint32&>(from) ) & 0xffff0000;
|
||||
#else
|
||||
tmp = (reinterpret_cast<const tensorflow::uint32&>(from) << 16) & 0xffff0000;
|
||||
#endif
|
||||
return reinterpret_cast<const float&>(tmp);
|
||||
}
|
||||
|
||||
@ -39,8 +44,12 @@ EIGEN_DEVICE_FUNC inline Packet pexpand_bf16_l(const Packet& from) {
|
||||
// in the upper 16-bits of input
|
||||
template <typename Packet>
|
||||
EIGEN_DEVICE_FUNC inline Packet pexpand_bf16_u(const Packet& from) {
|
||||
tensorflow::uint32 tmp =
|
||||
(reinterpret_cast<const tensorflow::uint32&>(from)) & 0xffff0000;
|
||||
tensorflow::uint32 tmp;
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
tmp = (reinterpret_cast<const tensorflow::uint32&>(from) << 16 ) & 0xffff0000;
|
||||
#else
|
||||
tmp = (reinterpret_cast<const tensorflow::uint32&>(from)) & 0xffff0000;
|
||||
#endif
|
||||
return reinterpret_cast<const float&>(tmp);
|
||||
}
|
||||
|
||||
|
@ -207,8 +207,13 @@ class SparseMatmulOpTest : public ::testing::Test {
|
||||
uint16_t* data3_p = reinterpret_cast<uint16_t*>(&data3[i]);
|
||||
uint16_t* data3_bfloat16_p =
|
||||
reinterpret_cast<uint16_t*>(data3_bfloat16) + i;
|
||||
data3_p[0] = 0;
|
||||
data3_bfloat16_p[0] = data3_p[1];
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
data3_p[1] = 0;
|
||||
data3_bfloat16_p[0] = data3_p[0];
|
||||
#else
|
||||
data3_p[0] = 0;
|
||||
data3_bfloat16_p[0] = data3_p[1];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class SparseSplitOp : public OpKernel {
|
||||
}
|
||||
|
||||
void Compute(OpKernelContext* context) override {
|
||||
const int32 split_dim = context->input(0).scalar<int>()();
|
||||
const int64 split_dim = context->input(0).scalar<int64>()();
|
||||
const Tensor& input_indices = context->input(1);
|
||||
const Tensor& input_values = context->input(2);
|
||||
const Tensor& input_shape = context->input(3);
|
||||
|
@ -24,7 +24,7 @@ namespace tensorflow {
|
||||
namespace port {
|
||||
|
||||
// TODO(jeff,sanjay): Make portable
|
||||
static const bool kLittleEndian = true;
|
||||
constexpr bool kLittleEndian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
|
||||
|
||||
// Returns an estimate of the number of schedulable CPUs for this
|
||||
// process. Usually, it's constant throughout the lifetime of a
|
||||
|
@ -48,6 +48,16 @@ public class ClassifierActivity extends CameraActivity implements OnImageAvailab
|
||||
// INPUT_NAME = "Mul:0", and OUTPUT_NAME = "final_result:0".
|
||||
// You'll also need to update the MODEL_FILE and LABEL_FILE paths to point to
|
||||
// the ones you produced.
|
||||
//
|
||||
// To use v3 Inception model, strip the DecodeJpeg Op from your retrained
|
||||
// model first:
|
||||
//
|
||||
// python strip_unused.py \
|
||||
// --input_graph=<retrained-pb-file> \
|
||||
// --output_graph=<your-stripped-pb-file> \
|
||||
// --input_node_names="Mul" \
|
||||
// --output_node_names="final_result" \
|
||||
// --input_binary=true
|
||||
private static final int NUM_CLASSES = 1001;
|
||||
private static final int INPUT_SIZE = 224;
|
||||
private static final int IMAGE_MEAN = 117;
|
||||
|
@ -52,7 +52,8 @@ def main(_):
|
||||
#
|
||||
# So here we use tf.nn.softmax_cross_entropy_with_logits on the raw
|
||||
# outputs of 'y', and then average across the batch.
|
||||
cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, y_))
|
||||
cross_entropy = tf.reduce_mean(
|
||||
tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y))
|
||||
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
|
||||
|
||||
config = tf.ConfigProto()
|
||||
|
@ -2044,7 +2044,7 @@ The attr `block_size` indicates the input block size and how the data is moved.
|
||||
|
||||
* Chunks of data of size `block_size * block_size` from depth are rearranged
|
||||
into non-overlapping blocks of size `block_size x block_size`
|
||||
* The width the output tensor is `input_depth * block_size`, whereas the
|
||||
* The width the output tensor is `input_width * block_size`, whereas the
|
||||
height is `input_height * block_size`.
|
||||
* The depth of the input tensor must be divisible by
|
||||
`block_size * block_size`.
|
||||
|
@ -10,7 +10,7 @@ The attr `block_size` indicates the input block size and how the data is moved.
|
||||
|
||||
* Chunks of data of size `block_size * block_size` from depth are rearranged
|
||||
into non-overlapping blocks of size `block_size x block_size`
|
||||
* The width the output tensor is `input_depth * block_size`, whereas the
|
||||
* The width the output tensor is `input_width * block_size`, whereas the
|
||||
height is `input_height * block_size`.
|
||||
* The depth of the input tensor must be divisible by
|
||||
`block_size * block_size`.
|
||||
|
@ -1,4 +1,185 @@
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ByteSize()` {#TaggedRunMetadata.ByteSize}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.Clear()` {#TaggedRunMetadata.Clear}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ClearExtension(extension_handle)` {#TaggedRunMetadata.ClearExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ClearField(field_name)` {#TaggedRunMetadata.ClearField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.CopyFrom(other_msg)` {#TaggedRunMetadata.CopyFrom}
|
||||
|
||||
Copies the content of the specified message into the current message.
|
||||
|
||||
The method clears the current message and then merges the specified
|
||||
message using MergeFrom.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`other_msg`</b>: Message to copy into the current one.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.DiscardUnknownFields()` {#TaggedRunMetadata.DiscardUnknownFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.FindInitializationErrors()` {#TaggedRunMetadata.FindInitializationErrors}
|
||||
|
||||
Finds required fields which are not initialized.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A list of strings. Each string is a path to an uninitialized field from
|
||||
the top-level message, e.g. "foo.bar[5].baz".
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.FromString(s)` {#TaggedRunMetadata.FromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.HasExtension(extension_handle)` {#TaggedRunMetadata.HasExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.HasField(field_name)` {#TaggedRunMetadata.HasField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.IsInitialized(errors=None)` {#TaggedRunMetadata.IsInitialized}
|
||||
|
||||
Checks if all required fields of a message are set.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`errors`</b>: A list which, if provided, will be populated with the field
|
||||
paths of all missing required fields.
|
||||
|
||||
##### Returns:
|
||||
|
||||
True iff the specified message has all required fields set.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ListFields()` {#TaggedRunMetadata.ListFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.MergeFrom(msg)` {#TaggedRunMetadata.MergeFrom}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.MergeFromString(serialized)` {#TaggedRunMetadata.MergeFromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ParseFromString(serialized)` {#TaggedRunMetadata.ParseFromString}
|
||||
|
||||
Parse serialized protocol buffer data into this message.
|
||||
|
||||
Like MergeFromString(), except we clear the object first and
|
||||
do not return the value that MergeFromString returns.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.RegisterExtension(extension_handle)` {#TaggedRunMetadata.RegisterExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SerializePartialToString()` {#TaggedRunMetadata.SerializePartialToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SerializeToString()` {#TaggedRunMetadata.SerializeToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SetInParent()` {#TaggedRunMetadata.SetInParent}
|
||||
|
||||
Sets the _cached_byte_size_dirty bit to true,
|
||||
and propagates this to our listener iff this was a state change.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.WhichOneof(oneof_name)` {#TaggedRunMetadata.WhichOneof}
|
||||
|
||||
Returns the name of the currently set field inside a oneof, or None.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__deepcopy__(memo=None)` {#TaggedRunMetadata.__deepcopy__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__eq__(other)` {#TaggedRunMetadata.__eq__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__getstate__()` {#TaggedRunMetadata.__getstate__}
|
||||
@ -6,3 +187,66 @@
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__hash__()` {#TaggedRunMetadata.__hash__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__init__(**kwargs)` {#TaggedRunMetadata.__init__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__ne__(other_msg)` {#TaggedRunMetadata.__ne__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__repr__()` {#TaggedRunMetadata.__repr__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__setstate__(state)` {#TaggedRunMetadata.__setstate__}
|
||||
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__str__()` {#TaggedRunMetadata.__str__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__unicode__()` {#TaggedRunMetadata.__unicode__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.run_metadata` {#TaggedRunMetadata.run_metadata}
|
||||
|
||||
Magic attribute generated for "run_metadata" proto field.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.tag` {#TaggedRunMetadata.tag}
|
||||
|
||||
Magic attribute generated for "tag" proto field.
|
||||
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
### `tf.merge_all_summaries(*args, **kwargs)` {#merge_all_summaries}
|
||||
|
||||
Merges all summaries collected in the default graph. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.merge_all.
|
||||
|
||||
Args:
|
||||
key: `GraphKey` used to collect the summaries. Defaults to
|
||||
`GraphKeys.SUMMARIES`.
|
||||
|
||||
Returns:
|
||||
If no summaries were collected, returns None. Otherwise returns a scalar
|
||||
`Tensor` of type `string` containing the serialized `Summary` protocol
|
||||
buffer resulting from the merging.
|
||||
|
@ -0,0 +1,49 @@
|
||||
### `tf.image_summary(*args, **kwargs)` {#image_summary}
|
||||
|
||||
Outputs a `Summary` protocol buffer with images. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.image. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, the max_images argument was renamed to max_outputs.
|
||||
|
||||
The summary has up to `max_images` summary values containing images. The
|
||||
images are built from `tensor` which must be 4-D with shape `[batch_size,
|
||||
height, width, channels]` and where `channels` can be:
|
||||
|
||||
* 1: `tensor` is interpreted as Grayscale.
|
||||
* 3: `tensor` is interpreted as RGB.
|
||||
* 4: `tensor` is interpreted as RGBA.
|
||||
|
||||
The images have the same number of channels as the input tensor. For float
|
||||
input, the values are normalized one image at a time to fit in the range
|
||||
`[0, 255]`. `uint8` values are unchanged. The op uses two different
|
||||
normalization algorithms:
|
||||
|
||||
* If the input values are all positive, they are rescaled so the largest one
|
||||
is 255.
|
||||
|
||||
* If any input value is negative, the values are shifted so input value 0.0
|
||||
is at 127. They are then rescaled so that either the smallest value is 0,
|
||||
or the largest one is 255.
|
||||
|
||||
The `tag` argument is a scalar `Tensor` of type `string`. It is used to
|
||||
build the `tag` of the summary values:
|
||||
|
||||
* If `max_images` is 1, the summary value tag is '*tag*/image'.
|
||||
* If `max_images` is greater than 1, the summary value tags are
|
||||
generated sequentially as '*tag*/image/0', '*tag*/image/1', etc.
|
||||
|
||||
Args:
|
||||
tag: A scalar `Tensor` of type `string`. Used to build the `tag`
|
||||
of the summary values.
|
||||
tensor: A 4-D `uint8` or `float32` `Tensor` of shape `[batch_size, height,
|
||||
width, channels]` where `channels` is 1, 3, or 4.
|
||||
max_images: Max number of batch elements to generate images for.
|
||||
collections: Optional list of ops.GraphKeys. The collections to add the
|
||||
summary to. Defaults to [ops.GraphKeys.SUMMARIES]
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Returns:
|
||||
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
|
||||
buffer.
|
||||
|
@ -1,4 +1,185 @@
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ByteSize()` {#SummaryDescription.ByteSize}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.Clear()` {#SummaryDescription.Clear}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ClearExtension(extension_handle)` {#SummaryDescription.ClearExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ClearField(field_name)` {#SummaryDescription.ClearField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.CopyFrom(other_msg)` {#SummaryDescription.CopyFrom}
|
||||
|
||||
Copies the content of the specified message into the current message.
|
||||
|
||||
The method clears the current message and then merges the specified
|
||||
message using MergeFrom.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`other_msg`</b>: Message to copy into the current one.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.DiscardUnknownFields()` {#SummaryDescription.DiscardUnknownFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.FindInitializationErrors()` {#SummaryDescription.FindInitializationErrors}
|
||||
|
||||
Finds required fields which are not initialized.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A list of strings. Each string is a path to an uninitialized field from
|
||||
the top-level message, e.g. "foo.bar[5].baz".
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.FromString(s)` {#SummaryDescription.FromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.HasExtension(extension_handle)` {#SummaryDescription.HasExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.HasField(field_name)` {#SummaryDescription.HasField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.IsInitialized(errors=None)` {#SummaryDescription.IsInitialized}
|
||||
|
||||
Checks if all required fields of a message are set.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`errors`</b>: A list which, if provided, will be populated with the field
|
||||
paths of all missing required fields.
|
||||
|
||||
##### Returns:
|
||||
|
||||
True iff the specified message has all required fields set.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ListFields()` {#SummaryDescription.ListFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.MergeFrom(msg)` {#SummaryDescription.MergeFrom}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.MergeFromString(serialized)` {#SummaryDescription.MergeFromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ParseFromString(serialized)` {#SummaryDescription.ParseFromString}
|
||||
|
||||
Parse serialized protocol buffer data into this message.
|
||||
|
||||
Like MergeFromString(), except we clear the object first and
|
||||
do not return the value that MergeFromString returns.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.RegisterExtension(extension_handle)` {#SummaryDescription.RegisterExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SerializePartialToString()` {#SummaryDescription.SerializePartialToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SerializeToString()` {#SummaryDescription.SerializeToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SetInParent()` {#SummaryDescription.SetInParent}
|
||||
|
||||
Sets the _cached_byte_size_dirty bit to true,
|
||||
and propagates this to our listener iff this was a state change.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.WhichOneof(oneof_name)` {#SummaryDescription.WhichOneof}
|
||||
|
||||
Returns the name of the currently set field inside a oneof, or None.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__deepcopy__(memo=None)` {#SummaryDescription.__deepcopy__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__eq__(other)` {#SummaryDescription.__eq__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__getstate__()` {#SummaryDescription.__getstate__}
|
||||
@ -6,3 +187,59 @@
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__hash__()` {#SummaryDescription.__hash__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__init__(**kwargs)` {#SummaryDescription.__init__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__ne__(other_msg)` {#SummaryDescription.__ne__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__repr__()` {#SummaryDescription.__repr__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__setstate__(state)` {#SummaryDescription.__setstate__}
|
||||
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__str__()` {#SummaryDescription.__str__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__unicode__()` {#SummaryDescription.__unicode__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.type_hint` {#SummaryDescription.type_hint}
|
||||
|
||||
Magic attribute generated for "type_hint" proto field.
|
||||
|
||||
|
||||
|
@ -173,125 +173,6 @@ Checks that for all elements of farray1 and farray2
|
||||
* <b>`err`</b>: a float value.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertBetween(value, minv, maxv, msg=None)` {#TestCase.assertBetween}
|
||||
|
||||
Asserts that value is between minv and maxv (inclusive).
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCommandFails(command, regexes, env=None, close_fds=True, msg=None)` {#TestCase.assertCommandFails}
|
||||
|
||||
Asserts a shell command fails and the error matches a regex in a list.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`command`</b>: List or string representing the command to run.
|
||||
* <b>`regexes`</b>: the list of regular expression strings.
|
||||
* <b>`env`</b>: Dictionary of environment variable settings.
|
||||
* <b>`close_fds`</b>: Whether or not to close all open fd's in the child after
|
||||
forking.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCommandSucceeds(command, regexes=('',), env=None, close_fds=True, msg=None)` {#TestCase.assertCommandSucceeds}
|
||||
|
||||
Asserts that a shell command succeeds (i.e. exits with code 0).
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`command`</b>: List or string representing the command to run.
|
||||
* <b>`regexes`</b>: List of regular expression byte strings that match success.
|
||||
* <b>`env`</b>: Dictionary of environment variable settings.
|
||||
* <b>`close_fds`</b>: Whether or not to close all open fd's in the child after
|
||||
forking.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsExactSubsequence(container, subsequence, msg=None)` {#TestCase.assertContainsExactSubsequence}
|
||||
|
||||
Assert that "container" contains "subsequence" as an exact subsequence.
|
||||
|
||||
Asserts that "container" contains all the elements of "subsequence", in
|
||||
order, and without other elements interspersed. For example, [1, 2, 3] is an
|
||||
exact subsequence of [0, 0, 1, 2, 3, 0] but not of [0, 0, 1, 2, 0, 3, 0].
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: the list we're testing for subsequence inclusion.
|
||||
* <b>`subsequence`</b>: the list we hope will be an exact subsequence of container.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsInOrder(strings, target, msg=None)` {#TestCase.assertContainsInOrder}
|
||||
|
||||
Asserts that the strings provided are found in the target in order.
|
||||
|
||||
This may be useful for checking HTML output.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`strings`</b>: A list of strings, such as [ 'fox', 'dog' ]
|
||||
* <b>`target`</b>: A target string in which to look for the strings, such as
|
||||
'The quick brown fox jumped over the lazy dog'.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsSubsequence(container, subsequence, msg=None)` {#TestCase.assertContainsSubsequence}
|
||||
|
||||
Assert that "container" contains "subsequence" as a subsequence.
|
||||
|
||||
Asserts that "container" contains all the elements of "subsequence", in
|
||||
order, but possibly with other elements interspersed. For example, [1, 2, 3]
|
||||
is a subsequence of [0, 0, 1, 2, 0, 3, 0] but not of [0, 0, 1, 3, 0, 2, 0].
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: the list we're testing for subsequence inclusion.
|
||||
* <b>`subsequence`</b>: the list we hope will be a subsequence of container.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsSubset(expected_subset, actual_set, msg=None)` {#TestCase.assertContainsSubset}
|
||||
|
||||
Checks whether actual iterable is a superset of expected iterable.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCountEqual(*args, **kwargs)` {#TestCase.assertCountEqual}
|
||||
|
||||
An unordered sequence specific comparison.
|
||||
|
||||
Equivalent to assertItemsEqual(). This method is a compatibility layer
|
||||
for Python 3k, since 2to3 does not convert assertItemsEqual() calls into
|
||||
assertCountEqual() calls.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertDeviceEqual(device1, device2)` {#TestCase.assertDeviceEqual}
|
||||
@ -314,48 +195,9 @@ Checks whether actual is a superset of expected.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertDictEqual(a, b, msg=None)` {#TestCase.assertDictEqual}
|
||||
|
||||
Raises AssertionError if a and b are not equal dictionaries.
|
||||
|
||||
##### Args:
|
||||
#### `tf.test.TestCase.assertDictEqual(d1, d2, msg=None)` {#TestCase.assertDictEqual}
|
||||
|
||||
|
||||
* <b>`a`</b>: A dict, the expected value.
|
||||
* <b>`b`</b>: A dict, the actual value.
|
||||
* <b>`msg`</b>: An optional str, the associated message.
|
||||
|
||||
##### Raises:
|
||||
|
||||
|
||||
* <b>`AssertionError`</b>: if the dictionaries are not equal.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertEmpty(container, msg=None)` {#TestCase.assertEmpty}
|
||||
|
||||
Assert that an object has zero length.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: Anything that implements the collections.Sized interface.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertEndsWith(actual, expected_end, msg=None)` {#TestCase.assertEndsWith}
|
||||
|
||||
Assert that actual.endswith(expected_end) is True.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`expected_end`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
@ -440,11 +282,10 @@ Included for symmetry with assertIsNone.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertItemsEqual(*args, **kwargs)` {#TestCase.assertItemsEqual}
|
||||
#### `tf.test.TestCase.assertItemsEqual(expected_seq, actual_seq, msg=None)` {#TestCase.assertItemsEqual}
|
||||
|
||||
An unordered sequence specific comparison.
|
||||
|
||||
It asserts that actual_seq and expected_seq have the same element counts.
|
||||
An unordered sequence specific comparison. It asserts that
|
||||
actual_seq and expected_seq have the same element counts.
|
||||
Equivalent to::
|
||||
|
||||
self.assertEqual(Counter(iter(actual_seq)),
|
||||
@ -457,30 +298,6 @@ Asserts that each element has the same count in both sequences.
|
||||
- [0, 1, 1] and [1, 0, 1] compare equal.
|
||||
- [0, 0, 1] and [0, 1] compare unequal.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertJsonEqual(first, second, msg=None)` {#TestCase.assertJsonEqual}
|
||||
|
||||
Asserts that the JSON objects defined in two strings are equal.
|
||||
|
||||
A summary of the differences will be included in the failure message
|
||||
using assertSameStructure.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`first`</b>: A string contining JSON to decode and compare to second.
|
||||
* <b>`second`</b>: A string contining JSON to decode and compare to first.
|
||||
* <b>`msg`</b>: Additional text to include in the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
@ -550,13 +367,6 @@ if not.
|
||||
* <b>`msg`</b>: An optional string message to append to the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNoCommonElements(expected_seq, actual_seq, msg=None)` {#TestCase.assertNoCommonElements}
|
||||
|
||||
Checks whether actual iterable and expected iterable are disjoint.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotAlmostEqual(first, second, places=None, msg=None, delta=None)` {#TestCase.assertNotAlmostEqual}
|
||||
@ -587,33 +397,6 @@ as significant digits (measured from the most signficant digit).
|
||||
Objects that are equal automatically fail.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEmpty(container, msg=None)` {#TestCase.assertNotEmpty}
|
||||
|
||||
Assert that an object has non-zero length.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: Anything that implements the collections.Sized interface.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEndsWith(actual, unexpected_end, msg=None)` {#TestCase.assertNotEndsWith}
|
||||
|
||||
Assert that actual.endswith(unexpected_end) is False.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`unexpected_end`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEqual(first, second, msg=None)` {#TestCase.assertNotEqual}
|
||||
@ -651,20 +434,6 @@ Included for symmetry with assertIsInstance.
|
||||
Fail the test if the text matches the regular expression.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotStartsWith(actual, unexpected_start, msg=None)` {#TestCase.assertNotStartsWith}
|
||||
|
||||
Assert that actual.startswith(unexpected_start) is False.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`unexpected_start`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertProtoEquals(expected_message_maybe_ascii, message)` {#TestCase.assertProtoEquals}
|
||||
@ -739,38 +508,6 @@ Asserts that the message in a raised exception matches a regexp.
|
||||
* <b>`kwargs`</b>: Extra kwargs.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithLiteralMatch(expected_exception, expected_exception_message, callable_obj=None, *args, **kwargs)` {#TestCase.assertRaisesWithLiteralMatch}
|
||||
|
||||
Asserts that the message in a raised exception equals the given string.
|
||||
|
||||
Unlike assertRaisesRegexp, this method takes a literal string, not
|
||||
a regular expression.
|
||||
|
||||
with self.assertRaisesWithLiteralMatch(ExType, 'message'):
|
||||
DoSomething()
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_exception`</b>: Exception class expected to be raised.
|
||||
* <b>`expected_exception_message`</b>: String message expected in the raised
|
||||
exception. For a raise exception e, expected_exception_message must
|
||||
equal str(e).
|
||||
* <b>`callable_obj`</b>: Function to be called, or None to return a context.
|
||||
* <b>`args`</b>: Extra args.
|
||||
* <b>`kwargs`</b>: Extra kwargs.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A context manager if callable_obj is None. Otherwise, None.
|
||||
|
||||
##### Raises:
|
||||
|
||||
self.failureException if callable_obj does not raise a macthing exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithPredicateMatch(exception_type, expected_err_re_or_predicate)` {#TestCase.assertRaisesWithPredicateMatch}
|
||||
@ -795,71 +532,6 @@ predicate search.
|
||||
exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithRegexpMatch(expected_exception, expected_regexp, callable_obj=None, *args, **kwargs)` {#TestCase.assertRaisesWithRegexpMatch}
|
||||
|
||||
Asserts that the message in a raised exception matches the given regexp.
|
||||
|
||||
This is just a wrapper around assertRaisesRegexp. Please use
|
||||
assertRaisesRegexp instead of assertRaisesWithRegexpMatch.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_exception`</b>: Exception class expected to be raised.
|
||||
* <b>`expected_regexp`</b>: Regexp (re pattern object or string) expected to be
|
||||
found in error message.
|
||||
* <b>`callable_obj`</b>: Function to be called, or None to return a context.
|
||||
* <b>`args`</b>: Extra args.
|
||||
* <b>`kwargs`</b>: Extra keyword args.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A context manager if callable_obj is None. Otherwise, None.
|
||||
|
||||
##### Raises:
|
||||
|
||||
self.failureException if callable_obj does not raise a macthing exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRegexMatch(actual_str, regexes, message=None)` {#TestCase.assertRegexMatch}
|
||||
|
||||
Asserts that at least one regex in regexes matches str.
|
||||
|
||||
If possible you should use assertRegexpMatches, which is a simpler
|
||||
version of this method. assertRegexpMatches takes a single regular
|
||||
expression (a string or re compiled object) instead of a list.
|
||||
|
||||
Notes:
|
||||
1. This function uses substring matching, i.e. the matching
|
||||
succeeds if *any* substring of the error message matches *any*
|
||||
regex in the list. This is more convenient for the user than
|
||||
full-string matching.
|
||||
|
||||
2. If regexes is the empty list, the matching will always fail.
|
||||
|
||||
3. Use regexes=[''] for a regex that will always pass.
|
||||
|
||||
4. '.' matches any single character *except* the newline. To
|
||||
match any character, use '(.|
|
||||
)'.
|
||||
|
||||
5. '^' matches the beginning of each line, not just the beginning
|
||||
of the string. Similarly, '$' matches the end of each line.
|
||||
|
||||
6. An exception will be thrown if regexes contains an invalid
|
||||
regex.
|
||||
|
||||
Args:
|
||||
actual_str: The string we try to match with the items in regexes.
|
||||
regexes: The regular expressions we want to match against str.
|
||||
See "Notes" above for detailed notes on how this is interpreted.
|
||||
message: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRegexpMatches(text, expected_regexp, msg=None)` {#TestCase.assertRegexpMatches}
|
||||
@ -867,79 +539,6 @@ Asserts that at least one regex in regexes matches str.
|
||||
Fail the test unless the text matches the regular expression.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSameElements(expected_seq, actual_seq, msg=None)` {#TestCase.assertSameElements}
|
||||
|
||||
Assert that two sequences have the same elements (in any order).
|
||||
|
||||
This method, unlike assertItemsEqual, doesn't care about any
|
||||
duplicates in the expected and actual sequences.
|
||||
|
||||
>> assertSameElements([1, 1, 1, 0, 0, 0], [0, 1])
|
||||
# Doesn't raise an AssertionError
|
||||
|
||||
If possible, you should use assertItemsEqual instead of
|
||||
assertSameElements.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSameStructure(a, b, aname='a', bname='b', msg=None)` {#TestCase.assertSameStructure}
|
||||
|
||||
Asserts that two values contain the same structural content.
|
||||
|
||||
The two arguments should be data trees consisting of trees of dicts and
|
||||
lists. They will be deeply compared by walking into the contents of dicts
|
||||
and lists; other items will be compared using the == operator.
|
||||
If the two structures differ in content, the failure message will indicate
|
||||
the location within the structures where the first difference is found.
|
||||
This may be helpful when comparing large structures.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`a`</b>: The first structure to compare.
|
||||
* <b>`b`</b>: The second structure to compare.
|
||||
* <b>`aname`</b>: Variable name to use for the first structure in assertion messages.
|
||||
* <b>`bname`</b>: Variable name to use for the second structure.
|
||||
* <b>`msg`</b>: Additional text to include in the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceAlmostEqual(expected_seq, actual_seq, places=None, msg=None, delta=None)` {#TestCase.assertSequenceAlmostEqual}
|
||||
|
||||
An approximate equality assertion for ordered sequences.
|
||||
|
||||
Fail if the two sequences are unequal as determined by their value
|
||||
differences rounded to the given number of decimal places (default 7) and
|
||||
comparing to zero, or by comparing that the difference between each value
|
||||
in the two sequences is more than the given delta.
|
||||
|
||||
Note that decimal places (from zero) are usually not the same as significant
|
||||
digits (measured from the most signficant digit).
|
||||
|
||||
If the two sequences compare equal then they will automatically compare
|
||||
almost equal.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`places`</b>: The number of decimal places to compare.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
* <b>`delta`</b>: The OK difference between compared values.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceEqual(seq1, seq2, msg=None, seq_type=None)` {#TestCase.assertSequenceEqual}
|
||||
@ -960,26 +559,6 @@ which can be indexed, has a length, and has an equality operator.
|
||||
differences.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceStartsWith(prefix, whole, msg=None)` {#TestCase.assertSequenceStartsWith}
|
||||
|
||||
An equality assertion for the beginning of ordered sequences.
|
||||
|
||||
If prefix is an empty sequence, it will raise an error unless whole is also
|
||||
an empty sequence.
|
||||
|
||||
If prefix is not a sequence, it will raise an error if the first element of
|
||||
whole does not match.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`prefix`</b>: A sequence expected at the beginning of the whole parameter.
|
||||
* <b>`whole`</b>: The sequence in which to look for prefix.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSetEqual(set1, set2, msg=None)` {#TestCase.assertSetEqual}
|
||||
@ -1031,51 +610,6 @@ Assert that actual.startswith(expected_start) is True.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertTotallyOrdered(*groups, **kwargs)` {#TestCase.assertTotallyOrdered}
|
||||
|
||||
Asserts that total ordering has been implemented correctly.
|
||||
|
||||
For example, say you have a class A that compares only on its attribute x.
|
||||
Comparators other than __lt__ are omitted for brevity.
|
||||
|
||||
class A(object):
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.x)
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
return self.x < other.x
|
||||
except AttributeError:
|
||||
return NotImplemented
|
||||
|
||||
assertTotallyOrdered will check that instances can be ordered correctly.
|
||||
For example,
|
||||
|
||||
self.assertTotallyOrdered(
|
||||
[None], # None should come before everything else.
|
||||
[1], # Integers sort earlier.
|
||||
[A(1, 'a')],
|
||||
[A(2, 'b')], # 2 is after 1.
|
||||
[A(3, 'c'), A(3, 'd')], # The second argument is irrelevant.
|
||||
[A(4, 'z')],
|
||||
['foo']) # Strings sort last.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`*groups`</b>: A list of groups of elements. Each group of elements is a list
|
||||
of objects that are equal. The elements in each group must be less than
|
||||
the elements in the group after it. For example, these groups are
|
||||
totally ordered: [None], [1], [2, 2], [3].
|
||||
* <b>`**kwargs`</b>: optional msg keyword argument can be passed.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertTrue(expr, msg=None)` {#TestCase.assertTrue}
|
||||
@ -1098,13 +632,6 @@ A tuple-specific equality assertion.
|
||||
differences.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertUrlEqual(a, b, msg=None)` {#TestCase.assertUrlEqual}
|
||||
|
||||
Asserts that urls are equal, ignoring ordering of query params.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assert_(expr, msg=None)` {#TestCase.assert_}
|
||||
@ -1166,9 +693,9 @@ tearDown.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.fail(msg=None, prefix=None)` {#TestCase.fail}
|
||||
#### `tf.test.TestCase.fail(msg=None)` {#TestCase.fail}
|
||||
|
||||
Fail immediately with the given message, optionally prefixed.
|
||||
Fail immediately, with the given message.
|
||||
|
||||
|
||||
- - -
|
||||
@ -1220,13 +747,6 @@ Fail immediately with the given message, optionally prefixed.
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.getRecordedProperties()` {#TestCase.getRecordedProperties}
|
||||
|
||||
Return any properties that the user has recorded.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.get_temp_dir()` {#TestCase.get_temp_dir}
|
||||
@ -1249,20 +769,6 @@ pollute each others environment.
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.recordProperty(property_name, property_value)` {#TestCase.recordProperty}
|
||||
|
||||
Record an arbitrary property for later use.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`property_name`</b>: str, name of property to record; must be a valid XML
|
||||
attribute name
|
||||
* <b>`property_value`</b>: value of property; must be valid XML attribute value
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.run(result=None)` {#TestCase.run}
|
||||
@ -1288,18 +794,11 @@ Hook method for setting up class fixture before running tests in the class.
|
||||
|
||||
#### `tf.test.TestCase.shortDescription()` {#TestCase.shortDescription}
|
||||
|
||||
Format both the test method name and the first line of its docstring.
|
||||
Returns a one-line description of the test, or None if no
|
||||
description has been provided.
|
||||
|
||||
If no docstring is given, only returns the method name.
|
||||
|
||||
This method overrides unittest.TestCase.shortDescription(), which
|
||||
only returns the first line of the docstring, obscuring the name
|
||||
of the test upon failure.
|
||||
|
||||
##### Returns:
|
||||
|
||||
|
||||
* <b>`desc`</b>: A short description of a test method.
|
||||
The default implementation of this method returns the first line of
|
||||
the specified test method's docstring.
|
||||
|
||||
|
||||
- - -
|
||||
|
@ -0,0 +1,22 @@
|
||||
### `tf.scalar_summary(*args, **kwargs)` {#scalar_summary}
|
||||
|
||||
Outputs a `Summary` protocol buffer with scalar values. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
|
||||
|
||||
The input `tags` and `values` must have the same shape. The generated
|
||||
summary has a summary value for each tag-value pair in `tags` and `values`.
|
||||
|
||||
Args:
|
||||
tags: A `string` `Tensor`. Tags for the summaries.
|
||||
values: A real numeric Tensor. Values for the summaries.
|
||||
collections: Optional list of graph collections keys. The new summary op is
|
||||
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Returns:
|
||||
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
|
||||
buffer.
|
||||
|
@ -0,0 +1,4 @@
|
||||
#### `tf.summary.SummaryDescription.RegisterExtension(extension_handle)` {#SummaryDescription.RegisterExtension}
|
||||
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
### `tf.histogram_summary(*args, **kwargs)` {#histogram_summary}
|
||||
|
||||
Outputs a `Summary` protocol buffer with a histogram. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.histogram. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on their scope.
|
||||
|
||||
The generated
|
||||
[`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
|
||||
has one summary value containing a histogram for `values`.
|
||||
|
||||
This op reports an `InvalidArgument` error if any value is not finite.
|
||||
|
||||
Args:
|
||||
tag: A `string` `Tensor`. 0-D. Tag to use for the summary value.
|
||||
values: A real numeric `Tensor`. Any shape. Values to use to
|
||||
build the histogram.
|
||||
collections: Optional list of graph collections keys. The new summary op is
|
||||
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Returns:
|
||||
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
|
||||
buffer.
|
||||
|
@ -0,0 +1,27 @@
|
||||
### `tf.merge_summary(*args, **kwargs)` {#merge_summary}
|
||||
|
||||
Merges summaries. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.merge.
|
||||
|
||||
This op creates a
|
||||
[`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
|
||||
protocol buffer that contains the union of all the values in the input
|
||||
summaries.
|
||||
|
||||
When the Op is run, it reports an `InvalidArgument` error if multiple values
|
||||
in the summaries to merge use the same tag.
|
||||
|
||||
Args:
|
||||
inputs: A list of `string` `Tensor` objects containing serialized `Summary`
|
||||
protocol buffers.
|
||||
collections: Optional list of graph collections keys. The new summary op is
|
||||
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Returns:
|
||||
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
|
||||
buffer resulting from the merging.
|
||||
|
@ -0,0 +1,4 @@
|
||||
#### `tf.summary.SummaryDescription.FromString(s)` {#SummaryDescription.FromString}
|
||||
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
#### `tf.summary.TaggedRunMetadata.RegisterExtension(extension_handle)` {#TaggedRunMetadata.RegisterExtension}
|
||||
|
||||
|
||||
|
@ -0,0 +1,207 @@
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.__init__(*args, **kwargs)` {#SummaryWriter.__init__}
|
||||
|
||||
Creates a `SummaryWriter` and an event file. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.FileWriter. The interface and behavior is the same; this is just a rename.
|
||||
|
||||
This class is deprecated, and should be replaced with tf.summary.FileWriter.
|
||||
|
||||
On construction the summary writer creates a new event file in `logdir`.
|
||||
This event file will contain `Event` protocol buffers constructed when you
|
||||
call one of the following functions: `add_summary()`, `add_session_log()`,
|
||||
`add_event()`, or `add_graph()`.
|
||||
|
||||
If you pass a `Graph` to the constructor it is added to
|
||||
the event file. (This is equivalent to calling `add_graph()` later).
|
||||
|
||||
TensorBoard will pick the graph from the file and display it graphically so
|
||||
you can interactively explore the graph you built. You will usually pass
|
||||
the graph from the session in which you launched it:
|
||||
|
||||
```python
|
||||
...create a graph...
|
||||
# Launch the graph in a session.
|
||||
sess = tf.Session()
|
||||
# Create a summary writer, add the 'graph' to the event file.
|
||||
writer = tf.train.SummaryWriter(<some-directory>, sess.graph)
|
||||
```
|
||||
|
||||
The other arguments to the constructor control the asynchronous writes to
|
||||
the event file:
|
||||
|
||||
* `flush_secs`: How often, in seconds, to flush the added summaries
|
||||
and events to disk.
|
||||
* `max_queue`: Maximum number of summaries or events pending to be
|
||||
written to disk before one of the 'add' calls block.
|
||||
|
||||
Args:
|
||||
logdir: A string. Directory where event file will be written.
|
||||
graph: A `Graph` object, such as `sess.graph`.
|
||||
max_queue: Integer. Size of the queue for pending events and summaries.
|
||||
flush_secs: Number. How often, in seconds, to flush the
|
||||
pending events and summaries to disk.
|
||||
graph_def: DEPRECATED: Use the `graph` argument instead.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_event(event)` {#SummaryWriter.add_event}
|
||||
|
||||
Adds an event to the event file.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`event`</b>: An `Event` protocol buffer.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_graph(graph, global_step=None, graph_def=None)` {#SummaryWriter.add_graph}
|
||||
|
||||
Adds a `Graph` to the event file.
|
||||
|
||||
The graph described by the protocol buffer will be displayed by
|
||||
TensorBoard. Most users pass a graph in the constructor instead.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`graph`</b>: A `Graph` object, such as `sess.graph`.
|
||||
* <b>`global_step`</b>: Number. Optional global step counter to record with the
|
||||
graph.
|
||||
* <b>`graph_def`</b>: DEPRECATED. Use the `graph` parameter instead.
|
||||
|
||||
##### Raises:
|
||||
|
||||
|
||||
* <b>`ValueError`</b>: If both graph and graph_def are passed to the method.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_meta_graph(meta_graph_def, global_step=None)` {#SummaryWriter.add_meta_graph}
|
||||
|
||||
Adds a `MetaGraphDef` to the event file.
|
||||
|
||||
The `MetaGraphDef` allows running the given graph via
|
||||
`saver.import_meta_graph()`.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`meta_graph_def`</b>: A `MetaGraphDef` object, often as retured by
|
||||
`saver.export_meta_graph()`.
|
||||
* <b>`global_step`</b>: Number. Optional global step counter to record with the
|
||||
graph.
|
||||
|
||||
##### Raises:
|
||||
|
||||
|
||||
* <b>`TypeError`</b>: If both `meta_graph_def` is not an instance of `MetaGraphDef`.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_run_metadata(run_metadata, tag, global_step=None)` {#SummaryWriter.add_run_metadata}
|
||||
|
||||
Adds a metadata information for a single session.run() call.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`run_metadata`</b>: A `RunMetadata` protobuf object.
|
||||
* <b>`tag`</b>: The tag name for this metadata.
|
||||
* <b>`global_step`</b>: Number. Optional global step counter to record with the
|
||||
StepStats.
|
||||
|
||||
##### Raises:
|
||||
|
||||
|
||||
* <b>`ValueError`</b>: If the provided tag was already used for this type of event.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_session_log(session_log, global_step=None)` {#SummaryWriter.add_session_log}
|
||||
|
||||
Adds a `SessionLog` protocol buffer to the event file.
|
||||
|
||||
This method wraps the provided session in an `Event` protocol buffer
|
||||
and adds it to the event file.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`session_log`</b>: A `SessionLog` protocol buffer.
|
||||
* <b>`global_step`</b>: Number. Optional global step value to record with the
|
||||
summary.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.add_summary(summary, global_step=None)` {#SummaryWriter.add_summary}
|
||||
|
||||
Adds a `Summary` protocol buffer to the event file.
|
||||
|
||||
This method wraps the provided summary in an `Event` protocol buffer
|
||||
and adds it to the event file.
|
||||
|
||||
You can pass the result of evaluating any summary op, using
|
||||
[`Session.run()`](client.md#Session.run) or
|
||||
[`Tensor.eval()`](framework.md#Tensor.eval), to this
|
||||
function. Alternatively, you can pass a `tf.Summary` protocol
|
||||
buffer that you populate with your own data. The latter is
|
||||
commonly done to report evaluation results in event files.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`summary`</b>: A `Summary` protocol buffer, optionally serialized as a string.
|
||||
* <b>`global_step`</b>: Number. Optional global step value to record with the
|
||||
summary.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.close()` {#SummaryWriter.close}
|
||||
|
||||
Flushes the event file to disk and close the file.
|
||||
|
||||
Call this method when you do not need the summary writer anymore.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.flush()` {#SummaryWriter.flush}
|
||||
|
||||
Flushes the event file to disk.
|
||||
|
||||
Call this method to make sure that all pending events have been written to
|
||||
disk.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.get_logdir()` {#SummaryWriter.get_logdir}
|
||||
|
||||
Returns the directory where event file will be written.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.train.SummaryWriter.reopen()` {#SummaryWriter.reopen}
|
||||
|
||||
Reopens the EventFileWriter.
|
||||
|
||||
Can be called after `close()` to add more events in the same directory.
|
||||
The events will go into a new events file.
|
||||
|
||||
Does nothing if the EventFileWriter was not closed.
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
### `tf.audio_summary(*args, **kwargs)` {#audio_summary}
|
||||
|
||||
Outputs a `Summary` protocol buffer with audio. (deprecated)
|
||||
|
||||
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-11-30.
|
||||
Instructions for updating:
|
||||
Please switch to tf.summary.audio. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in.
|
||||
|
||||
The summary has up to `max_outputs` summary values containing audio. The
|
||||
audio is built from `tensor` which must be 3-D with shape `[batch_size,
|
||||
frames, channels]` or 2-D with shape `[batch_size, frames]`. The values are
|
||||
assumed to be in the range of `[-1.0, 1.0]` with a sample rate of
|
||||
`sample_rate`.
|
||||
|
||||
The `tag` argument is a scalar `Tensor` of type `string`. It is used to
|
||||
build the `tag` of the summary values:
|
||||
|
||||
* If `max_outputs` is 1, the summary value tag is '*tag*/audio'.
|
||||
* If `max_outputs` is greater than 1, the summary value tags are
|
||||
generated sequentially as '*tag*/audio/0', '*tag*/audio/1', etc.
|
||||
|
||||
Args:
|
||||
tag: A scalar `Tensor` of type `string`. Used to build the `tag`
|
||||
of the summary values.
|
||||
tensor: A 3-D `float32` `Tensor` of shape `[batch_size, frames, channels]`
|
||||
or a 2-D `float32` `Tensor` of shape `[batch_size, frames]`.
|
||||
sample_rate: A Scalar `float32` `Tensor` indicating the sample rate of the
|
||||
signal in hertz.
|
||||
max_outputs: Max number of batch elements to generate audio for.
|
||||
collections: Optional list of ops.GraphKeys. The collections to add the
|
||||
summary to. Defaults to [ops.GraphKeys.SUMMARIES]
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Returns:
|
||||
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
|
||||
buffer.
|
||||
|
@ -0,0 +1,4 @@
|
||||
#### `tf.summary.TaggedRunMetadata.FromString(s)` {#TaggedRunMetadata.FromString}
|
||||
|
||||
|
||||
|
@ -485,6 +485,187 @@ metadata is stored in its NodeDef. This method retrieves the description.
|
||||
### `class tf.summary.SummaryDescription` {#SummaryDescription}
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ByteSize()` {#SummaryDescription.ByteSize}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.Clear()` {#SummaryDescription.Clear}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ClearExtension(extension_handle)` {#SummaryDescription.ClearExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ClearField(field_name)` {#SummaryDescription.ClearField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.CopyFrom(other_msg)` {#SummaryDescription.CopyFrom}
|
||||
|
||||
Copies the content of the specified message into the current message.
|
||||
|
||||
The method clears the current message and then merges the specified
|
||||
message using MergeFrom.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`other_msg`</b>: Message to copy into the current one.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.DiscardUnknownFields()` {#SummaryDescription.DiscardUnknownFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.FindInitializationErrors()` {#SummaryDescription.FindInitializationErrors}
|
||||
|
||||
Finds required fields which are not initialized.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A list of strings. Each string is a path to an uninitialized field from
|
||||
the top-level message, e.g. "foo.bar[5].baz".
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.FromString(s)` {#SummaryDescription.FromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.HasExtension(extension_handle)` {#SummaryDescription.HasExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.HasField(field_name)` {#SummaryDescription.HasField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.IsInitialized(errors=None)` {#SummaryDescription.IsInitialized}
|
||||
|
||||
Checks if all required fields of a message are set.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`errors`</b>: A list which, if provided, will be populated with the field
|
||||
paths of all missing required fields.
|
||||
|
||||
##### Returns:
|
||||
|
||||
True iff the specified message has all required fields set.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ListFields()` {#SummaryDescription.ListFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.MergeFrom(msg)` {#SummaryDescription.MergeFrom}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.MergeFromString(serialized)` {#SummaryDescription.MergeFromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.ParseFromString(serialized)` {#SummaryDescription.ParseFromString}
|
||||
|
||||
Parse serialized protocol buffer data into this message.
|
||||
|
||||
Like MergeFromString(), except we clear the object first and
|
||||
do not return the value that MergeFromString returns.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.RegisterExtension(extension_handle)` {#SummaryDescription.RegisterExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SerializePartialToString()` {#SummaryDescription.SerializePartialToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SerializeToString()` {#SummaryDescription.SerializeToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.SetInParent()` {#SummaryDescription.SetInParent}
|
||||
|
||||
Sets the _cached_byte_size_dirty bit to true,
|
||||
and propagates this to our listener iff this was a state change.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.WhichOneof(oneof_name)` {#SummaryDescription.WhichOneof}
|
||||
|
||||
Returns the name of the currently set field inside a oneof, or None.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__deepcopy__(memo=None)` {#SummaryDescription.__deepcopy__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__eq__(other)` {#SummaryDescription.__eq__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__getstate__()` {#SummaryDescription.__getstate__}
|
||||
@ -492,12 +673,249 @@ metadata is stored in its NodeDef. This method retrieves the description.
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__hash__()` {#SummaryDescription.__hash__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__init__(**kwargs)` {#SummaryDescription.__init__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__ne__(other_msg)` {#SummaryDescription.__ne__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__repr__()` {#SummaryDescription.__repr__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__setstate__(state)` {#SummaryDescription.__setstate__}
|
||||
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__str__()` {#SummaryDescription.__str__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.__unicode__()` {#SummaryDescription.__unicode__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.SummaryDescription.type_hint` {#SummaryDescription.type_hint}
|
||||
|
||||
Magic attribute generated for "type_hint" proto field.
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
### `class tf.summary.TaggedRunMetadata` {#TaggedRunMetadata}
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ByteSize()` {#TaggedRunMetadata.ByteSize}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.Clear()` {#TaggedRunMetadata.Clear}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ClearExtension(extension_handle)` {#TaggedRunMetadata.ClearExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ClearField(field_name)` {#TaggedRunMetadata.ClearField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.CopyFrom(other_msg)` {#TaggedRunMetadata.CopyFrom}
|
||||
|
||||
Copies the content of the specified message into the current message.
|
||||
|
||||
The method clears the current message and then merges the specified
|
||||
message using MergeFrom.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`other_msg`</b>: Message to copy into the current one.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.DiscardUnknownFields()` {#TaggedRunMetadata.DiscardUnknownFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.FindInitializationErrors()` {#TaggedRunMetadata.FindInitializationErrors}
|
||||
|
||||
Finds required fields which are not initialized.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A list of strings. Each string is a path to an uninitialized field from
|
||||
the top-level message, e.g. "foo.bar[5].baz".
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.FromString(s)` {#TaggedRunMetadata.FromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.HasExtension(extension_handle)` {#TaggedRunMetadata.HasExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.HasField(field_name)` {#TaggedRunMetadata.HasField}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.IsInitialized(errors=None)` {#TaggedRunMetadata.IsInitialized}
|
||||
|
||||
Checks if all required fields of a message are set.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`errors`</b>: A list which, if provided, will be populated with the field
|
||||
paths of all missing required fields.
|
||||
|
||||
##### Returns:
|
||||
|
||||
True iff the specified message has all required fields set.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ListFields()` {#TaggedRunMetadata.ListFields}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.MergeFrom(msg)` {#TaggedRunMetadata.MergeFrom}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.MergeFromString(serialized)` {#TaggedRunMetadata.MergeFromString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.ParseFromString(serialized)` {#TaggedRunMetadata.ParseFromString}
|
||||
|
||||
Parse serialized protocol buffer data into this message.
|
||||
|
||||
Like MergeFromString(), except we clear the object first and
|
||||
do not return the value that MergeFromString returns.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.RegisterExtension(extension_handle)` {#TaggedRunMetadata.RegisterExtension}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SerializePartialToString()` {#TaggedRunMetadata.SerializePartialToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SerializeToString()` {#TaggedRunMetadata.SerializeToString}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.SetInParent()` {#TaggedRunMetadata.SetInParent}
|
||||
|
||||
Sets the _cached_byte_size_dirty bit to true,
|
||||
and propagates this to our listener iff this was a state change.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.WhichOneof(oneof_name)` {#TaggedRunMetadata.WhichOneof}
|
||||
|
||||
Returns the name of the currently set field inside a oneof, or None.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__deepcopy__(memo=None)` {#TaggedRunMetadata.__deepcopy__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__eq__(other)` {#TaggedRunMetadata.__eq__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__getstate__()` {#TaggedRunMetadata.__getstate__}
|
||||
@ -505,4 +923,67 @@ Support the pickle protocol.
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__hash__()` {#TaggedRunMetadata.__hash__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__init__(**kwargs)` {#TaggedRunMetadata.__init__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__ne__(other_msg)` {#TaggedRunMetadata.__ne__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__repr__()` {#TaggedRunMetadata.__repr__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__setstate__(state)` {#TaggedRunMetadata.__setstate__}
|
||||
|
||||
Support the pickle protocol.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__str__()` {#TaggedRunMetadata.__str__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.__unicode__()` {#TaggedRunMetadata.__unicode__}
|
||||
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.run_metadata` {#TaggedRunMetadata.run_metadata}
|
||||
|
||||
Magic attribute generated for "run_metadata" proto field.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.summary.TaggedRunMetadata.tag` {#TaggedRunMetadata.tag}
|
||||
|
||||
Magic attribute generated for "tag" proto field.
|
||||
|
||||
|
||||
|
||||
|
@ -213,125 +213,6 @@ Checks that for all elements of farray1 and farray2
|
||||
* <b>`err`</b>: a float value.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertBetween(value, minv, maxv, msg=None)` {#TestCase.assertBetween}
|
||||
|
||||
Asserts that value is between minv and maxv (inclusive).
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCommandFails(command, regexes, env=None, close_fds=True, msg=None)` {#TestCase.assertCommandFails}
|
||||
|
||||
Asserts a shell command fails and the error matches a regex in a list.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`command`</b>: List or string representing the command to run.
|
||||
* <b>`regexes`</b>: the list of regular expression strings.
|
||||
* <b>`env`</b>: Dictionary of environment variable settings.
|
||||
* <b>`close_fds`</b>: Whether or not to close all open fd's in the child after
|
||||
forking.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCommandSucceeds(command, regexes=('',), env=None, close_fds=True, msg=None)` {#TestCase.assertCommandSucceeds}
|
||||
|
||||
Asserts that a shell command succeeds (i.e. exits with code 0).
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`command`</b>: List or string representing the command to run.
|
||||
* <b>`regexes`</b>: List of regular expression byte strings that match success.
|
||||
* <b>`env`</b>: Dictionary of environment variable settings.
|
||||
* <b>`close_fds`</b>: Whether or not to close all open fd's in the child after
|
||||
forking.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsExactSubsequence(container, subsequence, msg=None)` {#TestCase.assertContainsExactSubsequence}
|
||||
|
||||
Assert that "container" contains "subsequence" as an exact subsequence.
|
||||
|
||||
Asserts that "container" contains all the elements of "subsequence", in
|
||||
order, and without other elements interspersed. For example, [1, 2, 3] is an
|
||||
exact subsequence of [0, 0, 1, 2, 3, 0] but not of [0, 0, 1, 2, 0, 3, 0].
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: the list we're testing for subsequence inclusion.
|
||||
* <b>`subsequence`</b>: the list we hope will be an exact subsequence of container.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsInOrder(strings, target, msg=None)` {#TestCase.assertContainsInOrder}
|
||||
|
||||
Asserts that the strings provided are found in the target in order.
|
||||
|
||||
This may be useful for checking HTML output.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`strings`</b>: A list of strings, such as [ 'fox', 'dog' ]
|
||||
* <b>`target`</b>: A target string in which to look for the strings, such as
|
||||
'The quick brown fox jumped over the lazy dog'.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsSubsequence(container, subsequence, msg=None)` {#TestCase.assertContainsSubsequence}
|
||||
|
||||
Assert that "container" contains "subsequence" as a subsequence.
|
||||
|
||||
Asserts that "container" contains all the elements of "subsequence", in
|
||||
order, but possibly with other elements interspersed. For example, [1, 2, 3]
|
||||
is a subsequence of [0, 0, 1, 2, 0, 3, 0] but not of [0, 0, 1, 3, 0, 2, 0].
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: the list we're testing for subsequence inclusion.
|
||||
* <b>`subsequence`</b>: the list we hope will be a subsequence of container.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertContainsSubset(expected_subset, actual_set, msg=None)` {#TestCase.assertContainsSubset}
|
||||
|
||||
Checks whether actual iterable is a superset of expected iterable.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertCountEqual(*args, **kwargs)` {#TestCase.assertCountEqual}
|
||||
|
||||
An unordered sequence specific comparison.
|
||||
|
||||
Equivalent to assertItemsEqual(). This method is a compatibility layer
|
||||
for Python 3k, since 2to3 does not convert assertItemsEqual() calls into
|
||||
assertCountEqual() calls.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertDeviceEqual(device1, device2)` {#TestCase.assertDeviceEqual}
|
||||
@ -354,48 +235,9 @@ Checks whether actual is a superset of expected.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertDictEqual(a, b, msg=None)` {#TestCase.assertDictEqual}
|
||||
|
||||
Raises AssertionError if a and b are not equal dictionaries.
|
||||
|
||||
##### Args:
|
||||
#### `tf.test.TestCase.assertDictEqual(d1, d2, msg=None)` {#TestCase.assertDictEqual}
|
||||
|
||||
|
||||
* <b>`a`</b>: A dict, the expected value.
|
||||
* <b>`b`</b>: A dict, the actual value.
|
||||
* <b>`msg`</b>: An optional str, the associated message.
|
||||
|
||||
##### Raises:
|
||||
|
||||
|
||||
* <b>`AssertionError`</b>: if the dictionaries are not equal.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertEmpty(container, msg=None)` {#TestCase.assertEmpty}
|
||||
|
||||
Assert that an object has zero length.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: Anything that implements the collections.Sized interface.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertEndsWith(actual, expected_end, msg=None)` {#TestCase.assertEndsWith}
|
||||
|
||||
Assert that actual.endswith(expected_end) is True.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`expected_end`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
@ -480,11 +322,10 @@ Included for symmetry with assertIsNone.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertItemsEqual(*args, **kwargs)` {#TestCase.assertItemsEqual}
|
||||
#### `tf.test.TestCase.assertItemsEqual(expected_seq, actual_seq, msg=None)` {#TestCase.assertItemsEqual}
|
||||
|
||||
An unordered sequence specific comparison.
|
||||
|
||||
It asserts that actual_seq and expected_seq have the same element counts.
|
||||
An unordered sequence specific comparison. It asserts that
|
||||
actual_seq and expected_seq have the same element counts.
|
||||
Equivalent to::
|
||||
|
||||
self.assertEqual(Counter(iter(actual_seq)),
|
||||
@ -497,30 +338,6 @@ Asserts that each element has the same count in both sequences.
|
||||
- [0, 1, 1] and [1, 0, 1] compare equal.
|
||||
- [0, 0, 1] and [0, 1] compare unequal.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertJsonEqual(first, second, msg=None)` {#TestCase.assertJsonEqual}
|
||||
|
||||
Asserts that the JSON objects defined in two strings are equal.
|
||||
|
||||
A summary of the differences will be included in the failure message
|
||||
using assertSameStructure.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`first`</b>: A string contining JSON to decode and compare to second.
|
||||
* <b>`second`</b>: A string contining JSON to decode and compare to first.
|
||||
* <b>`msg`</b>: Additional text to include in the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
@ -590,13 +407,6 @@ if not.
|
||||
* <b>`msg`</b>: An optional string message to append to the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNoCommonElements(expected_seq, actual_seq, msg=None)` {#TestCase.assertNoCommonElements}
|
||||
|
||||
Checks whether actual iterable and expected iterable are disjoint.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotAlmostEqual(first, second, places=None, msg=None, delta=None)` {#TestCase.assertNotAlmostEqual}
|
||||
@ -627,33 +437,6 @@ as significant digits (measured from the most signficant digit).
|
||||
Objects that are equal automatically fail.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEmpty(container, msg=None)` {#TestCase.assertNotEmpty}
|
||||
|
||||
Assert that an object has non-zero length.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`container`</b>: Anything that implements the collections.Sized interface.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEndsWith(actual, unexpected_end, msg=None)` {#TestCase.assertNotEndsWith}
|
||||
|
||||
Assert that actual.endswith(unexpected_end) is False.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`unexpected_end`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotEqual(first, second, msg=None)` {#TestCase.assertNotEqual}
|
||||
@ -691,20 +474,6 @@ Included for symmetry with assertIsInstance.
|
||||
Fail the test if the text matches the regular expression.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertNotStartsWith(actual, unexpected_start, msg=None)` {#TestCase.assertNotStartsWith}
|
||||
|
||||
Assert that actual.startswith(unexpected_start) is False.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`actual`</b>: str
|
||||
* <b>`unexpected_start`</b>: str
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertProtoEquals(expected_message_maybe_ascii, message)` {#TestCase.assertProtoEquals}
|
||||
@ -779,38 +548,6 @@ Asserts that the message in a raised exception matches a regexp.
|
||||
* <b>`kwargs`</b>: Extra kwargs.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithLiteralMatch(expected_exception, expected_exception_message, callable_obj=None, *args, **kwargs)` {#TestCase.assertRaisesWithLiteralMatch}
|
||||
|
||||
Asserts that the message in a raised exception equals the given string.
|
||||
|
||||
Unlike assertRaisesRegexp, this method takes a literal string, not
|
||||
a regular expression.
|
||||
|
||||
with self.assertRaisesWithLiteralMatch(ExType, 'message'):
|
||||
DoSomething()
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_exception`</b>: Exception class expected to be raised.
|
||||
* <b>`expected_exception_message`</b>: String message expected in the raised
|
||||
exception. For a raise exception e, expected_exception_message must
|
||||
equal str(e).
|
||||
* <b>`callable_obj`</b>: Function to be called, or None to return a context.
|
||||
* <b>`args`</b>: Extra args.
|
||||
* <b>`kwargs`</b>: Extra kwargs.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A context manager if callable_obj is None. Otherwise, None.
|
||||
|
||||
##### Raises:
|
||||
|
||||
self.failureException if callable_obj does not raise a macthing exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithPredicateMatch(exception_type, expected_err_re_or_predicate)` {#TestCase.assertRaisesWithPredicateMatch}
|
||||
@ -835,71 +572,6 @@ predicate search.
|
||||
exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRaisesWithRegexpMatch(expected_exception, expected_regexp, callable_obj=None, *args, **kwargs)` {#TestCase.assertRaisesWithRegexpMatch}
|
||||
|
||||
Asserts that the message in a raised exception matches the given regexp.
|
||||
|
||||
This is just a wrapper around assertRaisesRegexp. Please use
|
||||
assertRaisesRegexp instead of assertRaisesWithRegexpMatch.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_exception`</b>: Exception class expected to be raised.
|
||||
* <b>`expected_regexp`</b>: Regexp (re pattern object or string) expected to be
|
||||
found in error message.
|
||||
* <b>`callable_obj`</b>: Function to be called, or None to return a context.
|
||||
* <b>`args`</b>: Extra args.
|
||||
* <b>`kwargs`</b>: Extra keyword args.
|
||||
|
||||
##### Returns:
|
||||
|
||||
A context manager if callable_obj is None. Otherwise, None.
|
||||
|
||||
##### Raises:
|
||||
|
||||
self.failureException if callable_obj does not raise a macthing exception.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRegexMatch(actual_str, regexes, message=None)` {#TestCase.assertRegexMatch}
|
||||
|
||||
Asserts that at least one regex in regexes matches str.
|
||||
|
||||
If possible you should use assertRegexpMatches, which is a simpler
|
||||
version of this method. assertRegexpMatches takes a single regular
|
||||
expression (a string or re compiled object) instead of a list.
|
||||
|
||||
Notes:
|
||||
1. This function uses substring matching, i.e. the matching
|
||||
succeeds if *any* substring of the error message matches *any*
|
||||
regex in the list. This is more convenient for the user than
|
||||
full-string matching.
|
||||
|
||||
2. If regexes is the empty list, the matching will always fail.
|
||||
|
||||
3. Use regexes=[''] for a regex that will always pass.
|
||||
|
||||
4. '.' matches any single character *except* the newline. To
|
||||
match any character, use '(.|
|
||||
)'.
|
||||
|
||||
5. '^' matches the beginning of each line, not just the beginning
|
||||
of the string. Similarly, '$' matches the end of each line.
|
||||
|
||||
6. An exception will be thrown if regexes contains an invalid
|
||||
regex.
|
||||
|
||||
Args:
|
||||
actual_str: The string we try to match with the items in regexes.
|
||||
regexes: The regular expressions we want to match against str.
|
||||
See "Notes" above for detailed notes on how this is interpreted.
|
||||
message: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertRegexpMatches(text, expected_regexp, msg=None)` {#TestCase.assertRegexpMatches}
|
||||
@ -907,79 +579,6 @@ Asserts that at least one regex in regexes matches str.
|
||||
Fail the test unless the text matches the regular expression.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSameElements(expected_seq, actual_seq, msg=None)` {#TestCase.assertSameElements}
|
||||
|
||||
Assert that two sequences have the same elements (in any order).
|
||||
|
||||
This method, unlike assertItemsEqual, doesn't care about any
|
||||
duplicates in the expected and actual sequences.
|
||||
|
||||
>> assertSameElements([1, 1, 1, 0, 0, 0], [0, 1])
|
||||
# Doesn't raise an AssertionError
|
||||
|
||||
If possible, you should use assertItemsEqual instead of
|
||||
assertSameElements.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSameStructure(a, b, aname='a', bname='b', msg=None)` {#TestCase.assertSameStructure}
|
||||
|
||||
Asserts that two values contain the same structural content.
|
||||
|
||||
The two arguments should be data trees consisting of trees of dicts and
|
||||
lists. They will be deeply compared by walking into the contents of dicts
|
||||
and lists; other items will be compared using the == operator.
|
||||
If the two structures differ in content, the failure message will indicate
|
||||
the location within the structures where the first difference is found.
|
||||
This may be helpful when comparing large structures.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`a`</b>: The first structure to compare.
|
||||
* <b>`b`</b>: The second structure to compare.
|
||||
* <b>`aname`</b>: Variable name to use for the first structure in assertion messages.
|
||||
* <b>`bname`</b>: Variable name to use for the second structure.
|
||||
* <b>`msg`</b>: Additional text to include in the failure message.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceAlmostEqual(expected_seq, actual_seq, places=None, msg=None, delta=None)` {#TestCase.assertSequenceAlmostEqual}
|
||||
|
||||
An approximate equality assertion for ordered sequences.
|
||||
|
||||
Fail if the two sequences are unequal as determined by their value
|
||||
differences rounded to the given number of decimal places (default 7) and
|
||||
comparing to zero, or by comparing that the difference between each value
|
||||
in the two sequences is more than the given delta.
|
||||
|
||||
Note that decimal places (from zero) are usually not the same as significant
|
||||
digits (measured from the most signficant digit).
|
||||
|
||||
If the two sequences compare equal then they will automatically compare
|
||||
almost equal.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`expected_seq`</b>: A sequence containing elements we are expecting.
|
||||
* <b>`actual_seq`</b>: The sequence that we are testing.
|
||||
* <b>`places`</b>: The number of decimal places to compare.
|
||||
* <b>`msg`</b>: The message to be printed if the test fails.
|
||||
* <b>`delta`</b>: The OK difference between compared values.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceEqual(seq1, seq2, msg=None, seq_type=None)` {#TestCase.assertSequenceEqual}
|
||||
@ -1000,26 +599,6 @@ which can be indexed, has a length, and has an equality operator.
|
||||
differences.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSequenceStartsWith(prefix, whole, msg=None)` {#TestCase.assertSequenceStartsWith}
|
||||
|
||||
An equality assertion for the beginning of ordered sequences.
|
||||
|
||||
If prefix is an empty sequence, it will raise an error unless whole is also
|
||||
an empty sequence.
|
||||
|
||||
If prefix is not a sequence, it will raise an error if the first element of
|
||||
whole does not match.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`prefix`</b>: A sequence expected at the beginning of the whole parameter.
|
||||
* <b>`whole`</b>: The sequence in which to look for prefix.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertSetEqual(set1, set2, msg=None)` {#TestCase.assertSetEqual}
|
||||
@ -1071,51 +650,6 @@ Assert that actual.startswith(expected_start) is True.
|
||||
* <b>`msg`</b>: Optional message to report on failure.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertTotallyOrdered(*groups, **kwargs)` {#TestCase.assertTotallyOrdered}
|
||||
|
||||
Asserts that total ordering has been implemented correctly.
|
||||
|
||||
For example, say you have a class A that compares only on its attribute x.
|
||||
Comparators other than __lt__ are omitted for brevity.
|
||||
|
||||
class A(object):
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.x)
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
return self.x < other.x
|
||||
except AttributeError:
|
||||
return NotImplemented
|
||||
|
||||
assertTotallyOrdered will check that instances can be ordered correctly.
|
||||
For example,
|
||||
|
||||
self.assertTotallyOrdered(
|
||||
[None], # None should come before everything else.
|
||||
[1], # Integers sort earlier.
|
||||
[A(1, 'a')],
|
||||
[A(2, 'b')], # 2 is after 1.
|
||||
[A(3, 'c'), A(3, 'd')], # The second argument is irrelevant.
|
||||
[A(4, 'z')],
|
||||
['foo']) # Strings sort last.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`*groups`</b>: A list of groups of elements. Each group of elements is a list
|
||||
of objects that are equal. The elements in each group must be less than
|
||||
the elements in the group after it. For example, these groups are
|
||||
totally ordered: [None], [1], [2, 2], [3].
|
||||
* <b>`**kwargs`</b>: optional msg keyword argument can be passed.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertTrue(expr, msg=None)` {#TestCase.assertTrue}
|
||||
@ -1138,13 +672,6 @@ A tuple-specific equality assertion.
|
||||
differences.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assertUrlEqual(a, b, msg=None)` {#TestCase.assertUrlEqual}
|
||||
|
||||
Asserts that urls are equal, ignoring ordering of query params.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.assert_(expr, msg=None)` {#TestCase.assert_}
|
||||
@ -1206,9 +733,9 @@ tearDown.
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.fail(msg=None, prefix=None)` {#TestCase.fail}
|
||||
#### `tf.test.TestCase.fail(msg=None)` {#TestCase.fail}
|
||||
|
||||
Fail immediately with the given message, optionally prefixed.
|
||||
Fail immediately, with the given message.
|
||||
|
||||
|
||||
- - -
|
||||
@ -1260,13 +787,6 @@ Fail immediately with the given message, optionally prefixed.
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.getRecordedProperties()` {#TestCase.getRecordedProperties}
|
||||
|
||||
Return any properties that the user has recorded.
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.get_temp_dir()` {#TestCase.get_temp_dir}
|
||||
@ -1289,20 +809,6 @@ pollute each others environment.
|
||||
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.recordProperty(property_name, property_value)` {#TestCase.recordProperty}
|
||||
|
||||
Record an arbitrary property for later use.
|
||||
|
||||
##### Args:
|
||||
|
||||
|
||||
* <b>`property_name`</b>: str, name of property to record; must be a valid XML
|
||||
attribute name
|
||||
* <b>`property_value`</b>: value of property; must be valid XML attribute value
|
||||
|
||||
|
||||
- - -
|
||||
|
||||
#### `tf.test.TestCase.run(result=None)` {#TestCase.run}
|
||||
@ -1328,18 +834,11 @@ Hook method for setting up class fixture before running tests in the class.
|
||||
|
||||
#### `tf.test.TestCase.shortDescription()` {#TestCase.shortDescription}
|
||||
|
||||
Format both the test method name and the first line of its docstring.
|
||||
Returns a one-line description of the test, or None if no
|
||||
description has been provided.
|
||||
|
||||
If no docstring is given, only returns the method name.
|
||||
|
||||
This method overrides unittest.TestCase.shortDescription(), which
|
||||
only returns the first line of the docstring, obscuring the name
|
||||
of the test upon failure.
|
||||
|
||||
##### Returns:
|
||||
|
||||
|
||||
* <b>`desc`</b>: A short description of a test method.
|
||||
The default implementation of this method returns the first line of
|
||||
the specified test method's docstring.
|
||||
|
||||
|
||||
- - -
|
||||
|
@ -19,6 +19,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
from tensorflow.python.framework import constant_op
|
||||
from tensorflow.python.framework import dtypes
|
||||
@ -46,33 +47,54 @@ class TensorUtilTest(test.TestCase):
|
||||
|
||||
def testFloatN(self):
|
||||
t = tensor_util.make_tensor_proto([10.0, 20.0, 30.0])
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([10.0, 20.0, 30.0], dtype=np.float32), a)
|
||||
|
||||
def testFloatTyped(self):
|
||||
t = tensor_util.make_tensor_proto([10.0, 20.0, 30.0], dtype=dtypes.float32)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([10.0, 20.0, 30.0], dtype=np.float32), a)
|
||||
|
||||
def testFloatTypeCoerce(self):
|
||||
t = tensor_util.make_tensor_proto([10, 20, 30], dtype=dtypes.float32)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([10.0, 20.0, 30.0], dtype=np.float32), a)
|
||||
@ -80,33 +102,54 @@ class TensorUtilTest(test.TestCase):
|
||||
def testFloatTypeCoerceNdarray(self):
|
||||
arr = np.asarray([10, 20, 30], dtype="int")
|
||||
t = tensor_util.make_tensor_proto(arr, dtype=dtypes.float32)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([10.0, 20.0, 30.0], dtype=np.float32), a)
|
||||
|
||||
def testFloatSizes(self):
|
||||
t = tensor_util.make_tensor_proto([10.0, 20.0, 30.0], shape=[1, 3])
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([[10.0, 20.0, 30.0]], dtype=np.float32), a)
|
||||
|
||||
def testFloatSizes2(self):
|
||||
t = tensor_util.make_tensor_proto([10.0, 20.0, 30.0], shape=[3, 1])
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } dim { size: 1 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } dim { size: 1 } }
|
||||
tensor_content: "A \000\000A\240\000\000A\360\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_FLOAT
|
||||
tensor_shape { dim { size: 3 } dim { size: 1 } }
|
||||
tensor_content: "\000\000 A\000\000\240A\000\000\360A"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float32, a.dtype)
|
||||
self.assertAllClose(np.array([[10.0], [20.0], [30.0]], dtype=np.float32), a)
|
||||
@ -123,11 +166,18 @@ class TensorUtilTest(test.TestCase):
|
||||
def testFloatNpArrayFloat64(self):
|
||||
t = tensor_util.make_tensor_proto(
|
||||
np.array([[10.0, 20.0, 30.0]], dtype=np.float64))
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_DOUBLE
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\000\000\000\000\000\000$@\000\000\000\000\000\0004@\000\000\000\000\000\000>@"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_DOUBLE
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "@$\000\000\000\000\000\000@4\000\000\000\000\000\000@>\000\000\000\000\000\000"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_DOUBLE
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\000\000\000\000\000\000$@\000\000\000\000\000\0004@\000\000\000\000\000\000>@"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.float64, a.dtype)
|
||||
self.assertAllClose(
|
||||
@ -207,11 +257,18 @@ class TensorUtilTest(test.TestCase):
|
||||
|
||||
def testIntNDefaultType(self):
|
||||
t = tensor_util.make_tensor_proto([10, 20, 30, 40], shape=[2, 2])
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT32
|
||||
tensor_shape { dim { size: 2 } dim { size: 2 } }
|
||||
tensor_content: "\\n\000\000\000\024\000\000\000\036\000\000\000(\000\000\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT32
|
||||
tensor_shape { dim { size: 2 } dim { size: 2 } }
|
||||
tensor_content: "\000\000\000\\n\000\000\000\024\000\000\000\036\000\000\000("
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT32
|
||||
tensor_shape { dim { size: 2 } dim { size: 2 } }
|
||||
tensor_content: "\\n\000\000\000\024\000\000\000\036\000\000\000(\000\000\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.int32, a.dtype)
|
||||
self.assertAllClose(np.array([[10, 20], [30, 40]], dtype=np.int32), a)
|
||||
@ -270,22 +327,36 @@ class TensorUtilTest(test.TestCase):
|
||||
def testLongN(self):
|
||||
t = tensor_util.make_tensor_proto(
|
||||
[10, 20, 30], shape=[1, 3], dtype=dtypes.int64)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\000\000\000\000\000\000\000\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 1 } dim { size: 3 } }
|
||||
tensor_content: "\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.int64, a.dtype)
|
||||
self.assertAllClose(np.array([[10, 20, 30]], dtype=np.int64), a)
|
||||
|
||||
def testLongNpArray(self):
|
||||
t = tensor_util.make_tensor_proto(np.array([10, 20, 30]))
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000\000\000\000\000\000\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_INT64
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\\n\000\000\000\000\000\000\000\024\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(np.int64, a.dtype)
|
||||
self.assertAllClose(np.array([10, 20, 30], dtype=np.int64), a)
|
||||
@ -295,11 +366,18 @@ class TensorUtilTest(test.TestCase):
|
||||
data = [(21,), (22,), (23,)]
|
||||
|
||||
t = tensor_util.make_tensor_proto(data, dtype=dtypes.qint32)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT32
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\000\000\026\000\000\000\027\000\000\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT32
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\000\000\025\000\000\000\026\000\000\000\027"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT32
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\000\000\026\000\000\000\027\000\000\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(dtypes.qint32.as_numpy_dtype, a.dtype)
|
||||
self.assertAllEqual(np.array(data, dtype=a.dtype), a)
|
||||
@ -325,21 +403,35 @@ class TensorUtilTest(test.TestCase):
|
||||
self.assertAllEqual(np.array(data, dtype=a.dtype), a)
|
||||
|
||||
t = tensor_util.make_tensor_proto(data, dtype=dtypes.quint16)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QUINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\026\000\027\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QUINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\025\000\026\000\027"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QUINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\026\000\027\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(dtypes.quint16.as_numpy_dtype, a.dtype)
|
||||
self.assertAllEqual(np.array(data, dtype=a.dtype), a)
|
||||
|
||||
t = tensor_util.make_tensor_proto(data, dtype=dtypes.qint16)
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\026\000\027\000"
|
||||
""", t)
|
||||
if sys.byteorder == "big":
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\000\025\000\026\000\027"
|
||||
""", t)
|
||||
else:
|
||||
self.assertProtoEquals("""
|
||||
dtype: DT_QINT16
|
||||
tensor_shape { dim { size: 3 } }
|
||||
tensor_content: "\025\000\026\000\027\000"
|
||||
""", t)
|
||||
a = tensor_util.MakeNdarray(t)
|
||||
self.assertEquals(dtypes.qint16.as_numpy_dtype, a.dtype)
|
||||
self.assertAllEqual(np.array(data, dtype=a.dtype), a)
|
||||
|
@ -19,6 +19,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
from tensorflow.python.framework import constant_op
|
||||
from tensorflow.python.framework import dtypes
|
||||
@ -142,8 +143,12 @@ class CastOpTest(test.TestCase):
|
||||
|
||||
self._compare(np.inf, np.float32, np.inf, False)
|
||||
self._compare(np.inf, np.float64, np.inf, False)
|
||||
self._compare(np.inf, np.int32, i4.min, False)
|
||||
self._compare(np.inf, np.int64, i8.min, False)
|
||||
if sys.byteorder == "big":
|
||||
self._compare(np.inf, np.int32, i4.max, False)
|
||||
self._compare(np.inf, np.int64, i8.max, False)
|
||||
else:
|
||||
self._compare(np.inf, np.int32, i4.min, False)
|
||||
self._compare(np.inf, np.int64, i8.min, False)
|
||||
self._compare(-np.inf, np.float32, -np.inf, False)
|
||||
self._compare(-np.inf, np.float64, -np.inf, False)
|
||||
self._compare(-np.inf, np.int32, i4.min, False)
|
||||
|
@ -55,7 +55,8 @@ class BatchNormalization(base._Layer): # pylint: disable=protected-access
|
||||
`data_format="channels_first"`, set `axis=1` in `BatchNormalization`.
|
||||
momentum: Momentum for the moving average.
|
||||
epsilon: Small float added to variance to avoid dividing by zero.
|
||||
center: If True, subtract `beta`. If False, `beta` is ignored.
|
||||
center: If True, add offset of `beta` to normalized tensor. If False, `beta`
|
||||
is ignored.
|
||||
scale: If True, multiply by `gamma`. If False, `gamma` is
|
||||
not used. When the next layer is linear (also e.g. `nn.relu`), this can be
|
||||
disabled since the scaling can be done by the next layer.
|
||||
@ -273,7 +274,8 @@ def batch_normalization(inputs,
|
||||
`data_format="channels_first"`, set `axis=1` in `BatchNormalization`.
|
||||
momentum: Momentum for the moving average.
|
||||
epsilon: Small float added to variance to avoid dividing by zero.
|
||||
center: If True, subtract `beta`. If False, `beta` is ignored.
|
||||
center: If True, add offset of `beta` to normalized tensor. If False, `beta`
|
||||
is ignored.
|
||||
scale: If True, multiply by `gamma`. If False, `gamma` is
|
||||
not used. When the next layer is linear (also e.g. `nn.relu`), this can be
|
||||
disabled since the scaling can be done by the next layer.
|
||||
|
@ -162,6 +162,10 @@ type and representation (RGB or HSV).
|
||||
@@draw_bounding_boxes
|
||||
@@non_max_suppression
|
||||
@@sample_distorted_bounding_box
|
||||
|
||||
## Denoising
|
||||
|
||||
@@total_variation
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
@ -1269,3 +1269,73 @@ def decode_image(contents, channels=None, name=None):
|
||||
|
||||
is_jpeg = math_ops.equal(substr, b'\xff\xd8\xff\xe0', name='is_jpeg')
|
||||
return control_flow_ops.cond(is_jpeg, _jpeg, check_png, name='cond_jpeg')
|
||||
|
||||
|
||||
def total_variation(images, name=None):
|
||||
"""Calculate and return the total variation for one or more images.
|
||||
|
||||
The total variation is the sum of the absolute differences for neighboring
|
||||
pixel-values in the input images. This measures how much noise is in the
|
||||
images.
|
||||
|
||||
This can be used as a loss-function during optimization so as to suppress
|
||||
noise in images. If you have a batch of images, then you should calculate
|
||||
the scalar loss-value as the sum:
|
||||
`loss = tf.reduce_sum(tf.image.total_variation(images))`
|
||||
|
||||
This implements the anisotropic 2-D version of the formula described here:
|
||||
|
||||
https://en.wikipedia.org/wiki/Total_variation_denoising
|
||||
|
||||
Args:
|
||||
images: 4-D Tensor of shape `[batch, height, width, channels]` or
|
||||
3-D Tensor of shape `[height, width, channels]`.
|
||||
|
||||
name: A name for the operation (optional).
|
||||
|
||||
Raises:
|
||||
ValueError: if images.shape is not a 3-D or 4-D vector.
|
||||
|
||||
Returns:
|
||||
The total variation of `images`.
|
||||
|
||||
If `images` was 4-D, return a 1-D float Tensor of shape `[batch]` with the
|
||||
total variation for each image in the batch.
|
||||
If `images` was 3-D, return a scalar float with the total variation for
|
||||
that image.
|
||||
"""
|
||||
|
||||
with ops.name_scope(name, 'total_variation'):
|
||||
ndims = images.get_shape().ndims
|
||||
|
||||
if ndims == 3:
|
||||
# The input is a single image with shape [height, width, channels].
|
||||
|
||||
# Calculate the difference of neighboring pixel-values.
|
||||
# The images are shifted one pixel along the height and width by slicing.
|
||||
pixel_dif1 = images[1:, :, :] - images[:-1, :, :]
|
||||
pixel_dif2 = images[:, 1:, :] - images[:, :-1, :]
|
||||
|
||||
# Sum for all axis. (None is an alias for all axis.)
|
||||
sum_axis = None
|
||||
elif ndims == 4:
|
||||
# The input is a batch of images with shape:
|
||||
# [batch, height, width, channels].
|
||||
|
||||
# Calculate the difference of neighboring pixel-values.
|
||||
# The images are shifted one pixel along the height and width by slicing.
|
||||
pixel_dif1 = images[:, 1:, :, :] - images[:, :-1, :, :]
|
||||
pixel_dif2 = images[:, :, 1:, :] - images[:, :, :-1, :]
|
||||
|
||||
# Only sum for the last 3 axis.
|
||||
# This results in a 1-D tensor with the total variation for each image.
|
||||
sum_axis = [1, 2, 3]
|
||||
else:
|
||||
raise ValueError('\'images\' must be either 3 or 4-dimensional.')
|
||||
|
||||
# Calculate the total variation by taking the absolute value of the
|
||||
# pixel-differences and summing over the appropriate axis.
|
||||
tot_var = math_ops.reduce_sum(math_ops.abs(pixel_dif1), axis=sum_axis) + \
|
||||
math_ops.reduce_sum(math_ops.abs(pixel_dif2), axis=sum_axis)
|
||||
|
||||
return tot_var
|
||||
|
@ -2405,5 +2405,186 @@ class ConvertImageTest(test_util.TensorFlowTestCase):
|
||||
[0, 255 * 256])
|
||||
|
||||
|
||||
class TotalVariationTest(test_util.TensorFlowTestCase):
|
||||
"""Tests the function total_variation() in image_ops.
|
||||
|
||||
We test a few small handmade examples, as well as
|
||||
some larger examples using an equivalent numpy
|
||||
implementation of the total_variation() function.
|
||||
|
||||
We do NOT test for overflows and invalid / edge-case arguments.
|
||||
"""
|
||||
|
||||
def _test(self, x_np, y_np):
|
||||
"""Test that the TensorFlow implementation of
|
||||
total_variation(x_np) calculates the values in y_np.
|
||||
|
||||
Note that these may be float-numbers so we only test
|
||||
for approximate equality within some narrow error-bound.
|
||||
"""
|
||||
|
||||
# Create a TensorFlow session.
|
||||
with self.test_session(use_gpu=True):
|
||||
# Add a constant to the TensorFlow graph that holds the input.
|
||||
x_tf = constant_op.constant(x_np, shape=x_np.shape)
|
||||
|
||||
# Add ops for calculating the total variation using TensorFlow.
|
||||
y = image_ops.total_variation(images=x_tf)
|
||||
|
||||
# Run the TensorFlow session to calculate the result.
|
||||
y_tf = y.eval()
|
||||
|
||||
# Assert that the results are as expected within
|
||||
# some small error-bound in case they are float-values.
|
||||
self.assertAllClose(y_tf, y_np)
|
||||
|
||||
def _total_variation_np(self, x_np):
|
||||
"""Calculate the total variation of x_np using numpy.
|
||||
This implements the same function as TensorFlow but
|
||||
using numpy instead.
|
||||
|
||||
Args:
|
||||
x_np: Numpy array with 3 or 4 dimensions.
|
||||
"""
|
||||
|
||||
dim = len(x_np.shape)
|
||||
|
||||
if dim == 3:
|
||||
# Calculate differences for neighboring pixel-values using slices.
|
||||
dif1 = x_np[1:, :, :] - x_np[:-1, :, :]
|
||||
dif2 = x_np[:, 1:, :] - x_np[:, :-1, :]
|
||||
|
||||
# Sum for all axis.
|
||||
sum_axis = None
|
||||
elif dim == 4:
|
||||
# Calculate differences for neighboring pixel-values using slices.
|
||||
dif1 = x_np[:, 1:, :, :] - x_np[:, :-1, :, :]
|
||||
dif2 = x_np[:, :, 1:, :] - x_np[:, :, :-1, :]
|
||||
|
||||
# Only sum for the last 3 axis.
|
||||
sum_axis = (1, 2, 3)
|
||||
else:
|
||||
# This should not occur in this test-code.
|
||||
pass
|
||||
|
||||
tot_var = np.sum(np.abs(dif1), axis=sum_axis) + \
|
||||
np.sum(np.abs(dif2), axis=sum_axis)
|
||||
|
||||
return tot_var
|
||||
|
||||
def _test_tensorflow_vs_numpy(self, x_np):
|
||||
"""Test the TensorFlow implementation against a numpy implementation.
|
||||
|
||||
Args:
|
||||
x_np: Numpy array with 3 or 4 dimensions.
|
||||
"""
|
||||
|
||||
# Calculate the y-values using the numpy implementation.
|
||||
y_np = self._total_variation_np(x_np)
|
||||
|
||||
self._test(x_np, y_np)
|
||||
|
||||
def _generateArray(self, shape):
|
||||
"""Generate an array of the given shape for use in testing.
|
||||
The numbers are calculated as the cumulative sum, which
|
||||
causes the difference between neighboring numbers to vary."""
|
||||
|
||||
# Flattened length of the array.
|
||||
flat_len = np.prod(shape)
|
||||
|
||||
a = np.array(range(flat_len), dtype=int)
|
||||
a = np.cumsum(a)
|
||||
a = a.reshape(shape)
|
||||
|
||||
return a
|
||||
|
||||
def testTotalVariationNumpy(self):
|
||||
"""Test the TensorFlow implementation against a numpy implementation.
|
||||
The two implementations are very similar so it is possible that both
|
||||
have the same bug, which would not be detected by this test. It is
|
||||
therefore necessary to test with manually crafted data as well."""
|
||||
|
||||
# Generate a test-array.
|
||||
# This is an 'image' with 100x80 pixels and 3 color channels.
|
||||
a = self._generateArray(shape=(100, 80, 3))
|
||||
|
||||
# Test the TensorFlow implementation vs. numpy implementation.
|
||||
# We use a numpy implementation to check the results that are
|
||||
# calculated using TensorFlow are correct.
|
||||
self._test_tensorflow_vs_numpy(a)
|
||||
self._test_tensorflow_vs_numpy(a + 1)
|
||||
self._test_tensorflow_vs_numpy(-a)
|
||||
self._test_tensorflow_vs_numpy(1.1 * a)
|
||||
|
||||
# Expand to a 4-dim array.
|
||||
b = a[np.newaxis, :]
|
||||
|
||||
# Combine several variations of the image into a single 4-dim array.
|
||||
multi = np.vstack((b, b + 1, -b, 1.1 * b))
|
||||
|
||||
# Test that the TensorFlow function can also handle 4-dim arrays.
|
||||
self._test_tensorflow_vs_numpy(multi)
|
||||
|
||||
def testTotalVariationHandmade(self):
|
||||
"""Test the total variation for a few handmade examples."""
|
||||
|
||||
# We create an image that is 2x2 pixels with 3 color channels.
|
||||
# The image is very small so we can check the result by hand.
|
||||
|
||||
# Red color channel.
|
||||
# The following are the sum of absolute differences between the pixels.
|
||||
# sum row dif = (4-1) + (7-2) = 3 + 5 = 8
|
||||
# sum col dif = (2-1) + (7-4) = 1 + 3 = 4
|
||||
r = [[1, 2],
|
||||
[4, 7]]
|
||||
|
||||
# Blue color channel.
|
||||
# sum row dif = 18 + 29 = 47
|
||||
# sum col dif = 7 + 18 = 25
|
||||
g = [[11, 18],
|
||||
[29, 47]]
|
||||
|
||||
# Green color channel.
|
||||
# sum row dif = 120 + 193 = 313
|
||||
# sum col dif = 47 + 120 = 167
|
||||
b = [[73, 120],
|
||||
[193, 313]]
|
||||
|
||||
# Combine the 3 color channels into a single 3-dim array.
|
||||
# The shape is (2, 2, 3) corresponding to (height, width and color).
|
||||
a = np.dstack((r, g, b))
|
||||
|
||||
# Total variation for this image.
|
||||
# Sum of all pixel differences = 8 + 4 + 47 + 25 + 313 + 167 = 564
|
||||
tot_var = 564
|
||||
|
||||
# Calculate the total variation using TensorFlow and assert it is correct.
|
||||
self._test(a, tot_var)
|
||||
|
||||
# If we add 1 to all pixel-values then the total variation is unchanged.
|
||||
self._test(a + 1, tot_var)
|
||||
|
||||
# If we negate all pixel-values then the total variation is unchanged.
|
||||
self._test(-a, tot_var)
|
||||
|
||||
# Scale the pixel-values by a float. This scales the total variation as well.
|
||||
b = 1.1 * a
|
||||
self._test(b, 1.1 * tot_var)
|
||||
|
||||
# Scale by another float.
|
||||
c = 1.2 * a
|
||||
self._test(c, 1.2 * tot_var)
|
||||
|
||||
# Combine these 3 images into a single array of shape (3, 2, 2, 3)
|
||||
# where the first dimension is for the image-number.
|
||||
multi = np.vstack((a[np.newaxis, :],
|
||||
b[np.newaxis, :],
|
||||
c[np.newaxis, :]))
|
||||
|
||||
# Check that TensorFlow correctly calculates the total variation
|
||||
# for each image individually and returns the correct array.
|
||||
self._test(multi, tot_var * np.array([1.0, 1.1, 1.2]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
googletest.main()
|
||||
|
@ -628,7 +628,7 @@ def _DivGrad(op, grad):
|
||||
y = math_ops.conj(y)
|
||||
return (array_ops.reshape(math_ops.reduce_sum(math_ops.div(grad, y), rx), sx),
|
||||
array_ops.reshape(
|
||||
math_ops.reduce_sum(grad * math_ops.div(-x, math_ops.square(y)),
|
||||
math_ops.reduce_sum(grad * math_ops.div(math_ops.div(-x, y), y),
|
||||
ry), sy))
|
||||
|
||||
|
||||
@ -658,7 +658,7 @@ def _RealDivGrad(op, grad):
|
||||
return (array_ops.reshape(
|
||||
math_ops.reduce_sum(math_ops.realdiv(grad, y), rx),
|
||||
sx), array_ops.reshape(
|
||||
math_ops.reduce_sum(grad * math_ops.realdiv(-x, math_ops.square(y)),
|
||||
math_ops.reduce_sum(grad * math_ops.realdiv(math_ops.realdiv(-x, y), y),
|
||||
ry), sy))
|
||||
|
||||
|
||||
|
@ -32,14 +32,12 @@
|
||||
|
||||
// Use optimized implementations whenever available
|
||||
#ifdef EIGEN_VECTORIZE_AVX512
|
||||
#include "src/Tensor/TensorContractionThreadPool.h"
|
||||
#include "src/FixedPoint/PacketMathAVX512.h"
|
||||
#include "src/FixedPoint/TypeCastingAVX512.h"
|
||||
|
||||
#elif defined EIGEN_VECTORIZE_AVX2
|
||||
#define EIGEN_USE_OPTIMIZED_INT8_UINT8_MAT_MAT_PRODUCT
|
||||
#define EIGEN_USE_OPTIMIZED_INT16_INT16_MAT_MAT_PRODUCT
|
||||
#include "src/Tensor/TensorContractionThreadPool.h"
|
||||
#include "src/FixedPoint/PacketMathAVX2.h"
|
||||
#include "src/FixedPoint/MatMatProductAVX2.h"
|
||||
#include "src/FixedPoint/TypeCastingAVX2.h"
|
||||
|
Loading…
Reference in New Issue
Block a user