Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypicks #10198

Merged
merged 10 commits into from May 25, 2017
27 changes: 24 additions & 3 deletions RELEASE.md
Expand Up @@ -3,9 +3,8 @@
## Major Features and Improvements
* Added `tf.layers.conv3d_transpose` layer for spatio temporal deconvolution.
* Added `tf.Session.make_callable()`, which provides a lower overhead means of running a similar step multiple times.
* Added libverbs-based RDMA support to contrib (courtesy @junshi15 from Yahoo).
* Bring `tf.feature_column.*` into the API. Non-deprecated functionality from `tf.contrib.layers.*` is moved to `tf.feature_column.*` with cosmetic changes.
* `RNNCell` objects now subclass `tf.layers._Layer`. The strictness described
* Added ibverbs-based RDMA support to contrib (courtesy @junshi15 from Yahoo).
* `RNNCell` objects now subclass `tf.layers.Layer`. The strictness described
in the TensorFlow 1.1 release is gone: The first time an RNNCell is used,
it caches its scope. All future uses of the RNNCell will reuse variables from
that same scope. This is a breaking change from the behavior of RNNCells
Expand All @@ -23,6 +22,28 @@
* TensorFlow C library now available for Windows.
* We released a new open-source version of TensorBoard.
* [`SavedModel CLI`](https://www.tensorflow.org/versions/master/programmers_guide/saved_model_cli) tool available to inspect and execute MetaGraph in SavedModel
* RNNCells' variable names have been renamed for consistency with Keras layers.
Specifically, the previous variable names "weights" and "biases" have
been changed to "kernel" and "bias", respectively.
This may cause backward incompatibility with regard to your old
checkpoints containing such RNN cells, in which case you can use the tool
[checkpoint_convert script](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/rnn/python/tools/checkpoint_convert.py)
to convert the variable names in your old checkpoints.
* Many of the RNN functions and classes that were in the `tf.nn` namespace
before the 1.0 release and which were moved to `tf.contrib.rnn` have now
been moved back to the core namespace. This includes
`RNNCell`, `LSTMCell`, `GRUCell`, and a number of other cells. These
now reside in `tf.nn.rnn_cell` (with aliases in `tf.contrib.rnn` for backwards
compatibility). The original `tf.nn.rnn` function is now `tf.nn.static_rnn`,
and the bidirectional static and state saving static rnn functions are also
now back in the `tf.nn` namespace.

Notable exceptions are the `EmbeddingWrapper`, `InputProjectionWrapper` and
`OutputProjectionWrapper`, which will slowly be moved to deprecation
in `tf.contrib.rnn`. These are inefficient wrappers that should often
be replaced by calling `embedding_lookup` or `layers.dense` as pre- or post-
processing of the rnn. For RNN decoding, this functionality has been replaced
with an alternative API in `tf.contrib.seq2seq`.

## Breaking Changes to the API
* `org.tensorflow.contrib.android.TensorFlowInferenceInterface` now throws exceptions where possible and has simplified method signatures.
Expand Down
19 changes: 11 additions & 8 deletions tensorflow/c/c_api.h
Expand Up @@ -961,8 +961,9 @@ typedef struct TF_WhileParams {
// - Reference-type inputs
// - Directly referencing external tensors from the cond/body graphs (this is
// possible in the Python API)
TF_WhileParams TF_NewWhile(TF_Graph* g, TF_Output* inputs, int ninputs,
TF_Status* status);
TF_CAPI_EXPORT extern TF_WhileParams TF_NewWhile(TF_Graph* g, TF_Output* inputs,
int ninputs,
TF_Status* status);

// Builds the while loop specified by `params` and returns the output tensors of
// the while loop in `outputs`. `outputs` should be allocated to size
Expand All @@ -972,13 +973,14 @@ TF_WhileParams TF_NewWhile(TF_Graph* g, TF_Output* inputs, int ninputs,
//
// Either this or TF_AbortWhile() must be called after a successful
// TF_NewWhile() call.
void TF_FinishWhile(const TF_WhileParams* params, TF_Status* status,
TF_Output* outputs);
TF_CAPI_EXPORT extern void TF_FinishWhile(const TF_WhileParams* params,
TF_Status* status,
TF_Output* outputs);

// Frees `params`s resources without building a while loop. `params` is no
// longer valid after this returns. Either this or TF_FinishWhile() must be
// called after a successful TF_NewWhile() call.
void TF_AbortWhile(const TF_WhileParams* params);
TF_CAPI_EXPORT extern void TF_AbortWhile(const TF_WhileParams* params);

// Adds operations to compute the partial derivatives of sum of `y`s w.r.t `x`s,
// i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...
Expand All @@ -994,8 +996,9 @@ void TF_AbortWhile(const TF_WhileParams* params);
// supports. See
// https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md
// for instructions on how to add C++ more gradients.
void TF_AddGradients(TF_Graph* g, TF_Output* y, int ny, TF_Output* x, int nx,
TF_Output* dx, TF_Status* status, TF_Output* dy);
TF_CAPI_EXPORT void TF_AddGradients(TF_Graph* g, TF_Output* y, int ny,
TF_Output* x, int nx, TF_Output* dx,
TF_Status* status, TF_Output* dy);

// TODO(josh11b): Register OpDef, available to all operations added
// to this graph.
Expand Down Expand Up @@ -1032,7 +1035,7 @@ TF_CAPI_EXPORT extern TF_Session* TF_NewSession(TF_Graph* graph,
//
// If successful, populates `graph` with the contents of the Graph and
// `meta_graph_def` with the MetaGraphDef of the loaded model.
TF_Session* TF_LoadSessionFromSavedModel(
TF_CAPI_EXPORT extern TF_Session* TF_LoadSessionFromSavedModel(
const TF_SessionOptions* session_options, const TF_Buffer* run_options,
const char* export_dir, const char* const* tags, int tags_len,
TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status);
Expand Down
9 changes: 8 additions & 1 deletion tensorflow/contrib/android/README.md
Expand Up @@ -27,10 +27,17 @@ allprojects {
}

dependencies {
compile 'org.tensorflow:tensorflow-android:1.2.0-preview'
compile 'org.tensorflow:tensorflow-android:+'
}
```

This will tell Gradle to use the
[latest version](https://bintray.com/google/tensorflow/tensorflow-android/_latestVersion)
of the TensorFlow AAR that has been released to
[https://bintray.com/google/tensorflow/tensorflow-android](https://bintray.com/google/tensorflow/tensorflow-android).
You may replace the `+` with an explicit version label if you wish to
use a specific release of TensorFlow in your app.

To build the libraries yourself (if, for example, you want to support custom
TensorFlow operators), pick your preferred approach below:

Expand Down
4 changes: 2 additions & 2 deletions tensorflow/contrib/crf/python/ops/crf.py
Expand Up @@ -41,11 +41,11 @@

import numpy as np

from tensorflow.contrib.rnn.python.ops import core_rnn_cell
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import rnn
from tensorflow.python.ops import rnn_cell
from tensorflow.python.ops import variable_scope as vs

__all__ = [
Expand Down Expand Up @@ -225,7 +225,7 @@ def crf_binary_score(tag_indices, sequence_lengths, transition_params):
return binary_scores


class CrfForwardRnnCell(core_rnn_cell.RNNCell):
class CrfForwardRnnCell(rnn_cell.RNNCell):
"""Computes the alpha values in a linear-chain CRF.

See http://www.cs.columbia.edu/~mcollins/fb.pdf for reference.
Expand Down
Expand Up @@ -22,7 +22,6 @@

from tensorflow.contrib.cudnn_rnn.python.ops import cudnn_rnn_ops
from tensorflow.contrib.rnn.python.ops import core_rnn
from tensorflow.contrib.rnn.python.ops import core_rnn_cell_impl
from tensorflow.contrib.rnn.python.ops import lstm_ops
from tensorflow.python.client import session
from tensorflow.python.framework import dtypes
Expand All @@ -31,6 +30,7 @@
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gradients_impl
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import rnn_cell
from tensorflow.python.ops import variables
from tensorflow.python.platform import test

Expand Down Expand Up @@ -131,9 +131,9 @@ def benchmarkTfRNNLSTMTraining(self):
]
initializer = init_ops.random_uniform_initializer(-0.01, 0.01, seed=127)

cell = core_rnn_cell_impl.LSTMCell(
cell = rnn_cell.LSTMCell(
num_units=num_units, initializer=initializer, state_is_tuple=True)
multi_cell = core_rnn_cell_impl.MultiRNNCell(
multi_cell = rnn_cell.MultiRNNCell(
[cell() for _ in range(num_layers)])
outputs, final_state = core_rnn.static_rnn(
multi_cell, inputs, dtype=dtypes.float32)
Expand All @@ -159,7 +159,7 @@ def benchmarkTfRNNLSTMBlockCellTraining(self):
]
cell = lambda: lstm_ops.LSTMBlockCell(num_units=num_units) # pylint: disable=cell-var-from-loop

multi_cell = core_rnn_cell_impl.MultiRNNCell(
multi_cell = rnn_cell.MultiRNNCell(
[cell() for _ in range(num_layers)])
outputs, final_state = core_rnn.static_rnn(
multi_cell, inputs, dtype=dtypes.float32)
Expand Down
12 changes: 6 additions & 6 deletions tensorflow/contrib/grid_rnn/python/kernel_tests/grid_rnn_test.py
Expand Up @@ -21,11 +21,11 @@
import numpy as np

from tensorflow.contrib.grid_rnn.python.ops import grid_rnn_cell
from tensorflow.contrib.rnn.python.ops import core_rnn
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import nn_ops
from tensorflow.python.ops import rnn
from tensorflow.python.ops import variable_scope
from tensorflow.python.ops import variables
from tensorflow.python.platform import test
Expand Down Expand Up @@ -527,7 +527,7 @@ def testGrid2LSTMCellWithRNN(self):
dtypes.float32, shape=(batch_size, input_size))
]

outputs, state = core_rnn.static_rnn(cell, inputs, dtype=dtypes.float32)
outputs, state = rnn.static_rnn(cell, inputs, dtype=dtypes.float32)

self.assertEqual(len(outputs), len(inputs))
self.assertEqual(state[0].c.get_shape(), (batch_size, 2))
Expand Down Expand Up @@ -569,7 +569,7 @@ def testGrid2LSTMCellReLUWithRNN(self):
array_ops.placeholder(dtypes.float32, shape=(batch_size, input_size))
]

outputs, state = core_rnn.static_rnn(cell, inputs, dtype=dtypes.float32)
outputs, state = rnn.static_rnn(cell, inputs, dtype=dtypes.float32)

self.assertEqual(len(outputs), len(inputs))
self.assertEqual(state[0].c.get_shape(), (batch_size, 2))
Expand Down Expand Up @@ -609,7 +609,7 @@ def testGrid3LSTMCellReLUWithRNN(self):
array_ops.placeholder(dtypes.float32, shape=(batch_size, input_size))
]

outputs, state = core_rnn.static_rnn(cell, inputs, dtype=dtypes.float32)
outputs, state = rnn.static_rnn(cell, inputs, dtype=dtypes.float32)

self.assertEqual(len(outputs), len(inputs))
self.assertEqual(state[0].c.get_shape(), (batch_size, 2))
Expand Down Expand Up @@ -652,7 +652,7 @@ def testGrid1LSTMCellWithRNN(self):
dtypes.float32, shape=(batch_size, input_size))
] + (max_length - 1) * [array_ops.zeros([batch_size, input_size])])

outputs, state = core_rnn.static_rnn(cell, inputs, dtype=dtypes.float32)
outputs, state = rnn.static_rnn(cell, inputs, dtype=dtypes.float32)

self.assertEqual(len(outputs), len(inputs))
self.assertEqual(state[0].c.get_shape(), (batch_size, 2))
Expand Down Expand Up @@ -690,7 +690,7 @@ def testGrid2LSTMCellWithRNNAndDynamicBatchSize(self):
array_ops.placeholder(dtypes.float32, shape=(None, input_size))
]

outputs, state = core_rnn.static_rnn(cell, inputs, dtype=dtypes.float32)
outputs, state = rnn.static_rnn(cell, inputs, dtype=dtypes.float32)

self.assertEqual(len(outputs), len(inputs))

Expand Down
Expand Up @@ -31,7 +31,6 @@
from tensorflow.contrib.learn.python.learn.estimators import prediction_key
from tensorflow.contrib.learn.python.learn.estimators import rnn_common
from tensorflow.contrib.learn.python.learn.estimators import run_config
from tensorflow.contrib.rnn.python.ops import core_rnn_cell_impl
from tensorflow.python.client import session
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
Expand All @@ -42,6 +41,7 @@
from tensorflow.python.ops import lookup_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import rnn_cell
from tensorflow.python.ops import variables
from tensorflow.python.platform import test

Expand Down Expand Up @@ -107,7 +107,7 @@ class DynamicRnnEstimatorTest(test.TestCase):

def setUp(self):
super(DynamicRnnEstimatorTest, self).setUp()
self.rnn_cell = core_rnn_cell_impl.BasicRNNCell(self.NUM_RNN_CELL_UNITS)
self.rnn_cell = rnn_cell.BasicRNNCell(self.NUM_RNN_CELL_UNITS)
self.mock_target_column = MockTargetColumn(
num_label_columns=self.NUM_LABEL_COLUMNS)

Expand Down Expand Up @@ -312,19 +312,19 @@ def testStateTupleDictConversion(self):
# A MultiRNNCell of LSTMCells is both a common choice and an interesting
# test case, because it has two levels of nesting, with an inner class that
# is not a plain tuple.
cell = core_rnn_cell_impl.MultiRNNCell(
[core_rnn_cell_impl.LSTMCell(i) for i in cell_sizes])
cell = rnn_cell.MultiRNNCell(
[rnn_cell.LSTMCell(i) for i in cell_sizes])
state_dict = {
dynamic_rnn_estimator._get_state_name(i):
array_ops.expand_dims(math_ops.range(cell_size), 0)
for i, cell_size in enumerate([5, 5, 3, 3, 7, 7])
}
expected_state = (core_rnn_cell_impl.LSTMStateTuple(
expected_state = (rnn_cell.LSTMStateTuple(
np.reshape(np.arange(5), [1, -1]), np.reshape(np.arange(5), [1, -1])),
core_rnn_cell_impl.LSTMStateTuple(
rnn_cell.LSTMStateTuple(
np.reshape(np.arange(3), [1, -1]),
np.reshape(np.arange(3), [1, -1])),
core_rnn_cell_impl.LSTMStateTuple(
rnn_cell.LSTMStateTuple(
np.reshape(np.arange(7), [1, -1]),
np.reshape(np.arange(7), [1, -1])))
actual_state = dynamic_rnn_estimator.dict_to_state_tuple(state_dict, cell)
Expand Down
Expand Up @@ -26,13 +26,13 @@
from tensorflow.contrib.learn.python.learn.estimators import estimator
from tensorflow.contrib.learn.python.learn.estimators import model_fn
from tensorflow.contrib.learn.python.learn.estimators import rnn_common
from tensorflow.contrib.rnn.python.ops import core_rnn
from tensorflow.contrib.training.python.training import sequence_queueing_state_saver as sqss
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import sparse_tensor
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import rnn
from tensorflow.python.training import momentum as momentum_opt
from tensorflow.python.util import nest

Expand Down Expand Up @@ -64,7 +64,7 @@ def construct_state_saving_rnn(cell,
final_state: The final state output by the RNN
"""
with ops.name_scope(scope):
rnn_outputs, final_state = core_rnn.static_state_saving_rnn(
rnn_outputs, final_state = rnn.static_state_saving_rnn(
cell=cell,
inputs=inputs,
state_saver=state_saver,
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/contrib/learn/python/learn/ops/seq2seq_ops_test.py
Expand Up @@ -21,9 +21,9 @@
import numpy as np

from tensorflow.contrib.learn.python.learn import ops
from tensorflow.contrib.rnn.python.ops import core_rnn_cell_impl
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import rnn_cell
from tensorflow.python.platform import test


Expand Down Expand Up @@ -82,7 +82,7 @@ def test_rnn_decoder(self):
array_ops.placeholder(dtypes.float32, [2, 2]) for _ in range(3)
]
encoding = array_ops.placeholder(dtypes.float32, [2, 2])
cell = core_rnn_cell_impl.GRUCell(2)
cell = rnn_cell.GRUCell(2)
outputs, states, sampling_outputs, sampling_states = (
ops.rnn_decoder(decoder_inputs, encoding, cell))
self.assertEqual(len(outputs), 3)
Expand Down