-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Reduce usage of tf.compat.v1 APIs #1718
Comments
TF 2.0 is removing tf.app. Instead of staying at tf.compat.v1.app, we are now using absl.app. This change also deprecates the usages of tf.app.run without py_binary build target (event_file_inspector and event_file_loader). Have manually tested all the impacted targets by executing them. Relates to #1718.
TF 2.0 is removing symbols for GraphDef and MetaGraphDef protos. We are converting it to TB proto definitions instead. Relates to tensorflow#1718.
TF is deprecating tf.flags. Migrate to absl. Note that absl.flags by itself does not parse sys.argv like [1] indicates. However, it is passed as part of `absl.app.run` [2] which we use, so the change should have no behavioral difference. Confirmed that the flags are parsed as expected by manually running the demos and script/tools. [1]: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/platform/flags.py#L66 [2]: https://github.com/abseil/abseil-py/blob/master/absl/app.py#L292 Related to #1718.
TF 2.0 is removing symbols for GraphDef and MetaGraphDef protos. We are converting it to TB proto definitions instead. Relates to #1718.
GFile was omitted from V2 API by mistake and the migration script misbehaved. Now that TF has fixed it, we now want to use the V2 API. Relates to #1718.
TF 2.0 image API has changed tiny bit in API signature in a way that does not impact us. We convert to the new 2.0 API and adopted the suggestion from TF deprecation message[1]. Confirmed correctness by running the beholder (based on demo data) and What-If tool (by supplying example file). Relates to #1718. [1]: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/image_ops_impl.py#L2987
@stephanwlee @nfelt can I work on the remaining ones, the two mentioned |
I recently learned about https://github.com/tensorflow/io which now includes ffmpeg. |
I think tensorflow/io's ffmpeg support is only for VideoDataset, i.e. it's only for reading videos. For the v2 audio summary op we can just use For the v1 audio summary op and the v1 audio_pb function (which uses contrib ffmpeg via PersistentOpEvaluator), we could either backport the use of For the v2 equivalent of audio_pb, we should just use the python standard library's Lastly, the Beholder plugin uses ffmpeg to encode videos, but it literally just shells out to ffmpeg so there's no usage of @amanp592 if you'd like to work on any of this, this could also be a good place to start. |
fwiw, I have noted extremely poor performance of the By contrast, from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import tempfile
import time
class Timer(object):
def __init__(self):
self._last = time.time()
def log(self, msg):
now = time.time()
print("[%0.3f] %s" % (now - self._last, msg))
self._last = now
SAMPLE_LEN = 13230000
def main():
t = Timer()
import tensorflow as tf
t.log("Loaded TensorFlow.")
audio = tf.random.uniform(shape=(SAMPLE_LEN, 2)) * 2 - 1
t.log("Generated audio (%d samples)." % SAMPLE_LEN)
encoded = tf.audio.encode_wav(audio, sample_rate=44100).numpy()
t.log("Encoded audio.")
filename = os.path.join(tempfile.mkdtemp(), "noise.wav")
with open(filename, "w") as outfile:
outfile.write(encoded)
t.log("Wrote to: %s" % filename)
if __name__ == "__main__":
main()
All this to say: we should benchmark, at least roughly, before and after |
A belated response to the comment about WAV encoding - I agree that we should benchmark. That said, I am not sure the above article really establishes that the Looking at the So I don't see any particular reason why |
what for this line of code : 'tf.compat.v1.summary.image' |
@HebaGamalElDin: The If you’re seeing that error when running TensorBoard, please open a |
@wchargin : what for python 2.7 , as almost Tensorrflow version 1.13 , 1.14 isn't applicable for python 2.7 . |
@HebaGamalElDin: TensorFlow versions 1.13 and 1.14 work just fine on >>> import tensorflow, sys
>>> sys.version
'2.7.16 (default, Apr 6 2019, 01:42:57) \n[GCC 7.3.0]'
>>> tensorflow.__version__
'1.13.1' >>> import tensorflow, sys
>>> sys.version
'2.7.16 (default, Apr 6 2019, 01:42:57) \n[GCC 7.3.0]'
>>> tensorflow.__version__
'1.14.0-rc0' TensorFlow will support Python 2.7 at least until its end of life, |
@wchargin : I have searched more for that version of tensorflow for windows but I just found the applicable versions for Linux and mac OS only . |
@HebaGamalElDin: I was able to install TensorFlow 1.13 on Windows If you continue to have problems installing TensorFlow, please consult |
TensorBoard have migrated to TF 2.0 APIs but there are some usages of V1 APIs due to not-so-compatible changes. Since we are interested in moving off of
tf.compat.v1
, we will either have to find a replacement or introduce some changes in behavior.Do note that this list exclude v1 API usages in tests (they are mainly written in graph style and is tracked in #1705) and TB v1 summary.
tf.compat.v1.app
->absl.app
tf.compat.v1.flags
->absl.flags
tf.compat.v1.gfile.GFile
->io.gfile.GFile
tf.compat.v1.gfile.Open
->io.gfile.GFile
tf.compat.v1.image.resize_images
->tf.image.resize
tf.compat.v1.image.resize_nearest_neighbor
->tf.image.resize
tf.compat.v1.GraphDef
-> TB prototf.compat.v1.MetaGraphDef
-> TB prototf.compat.v1.RunMetadata
-> TB prototf.compat.v1.SessionLog
-> TB prototf.compat.v1.pywrap_tensorflow.NewCheckpointReader
->tf.train.load_checkpoint
tf.compat.v1.checkpoint_exists
->tf.io.gfile.glob()
for the prefixtf.compat.v1.Session
-> Use eager modetf.contrib.ffmpeg
->tf.audio.encode_wav
or python stdlib'swave
module(obsolete)tf.contrib.summary.create_db_writer
-> replace with python implementationtf.compat.v1.pywrap_tensorflow.EventsWriter
-> migrated totensorflow.python._pywrap_events_writer
private API via Update TensorBoard to import pywrap_tensorflow from tensorflow.python #2096 and then Use _pywrap_events_writer #2683.tf.compat.v1.io.tf_record_iterator
-> tracked in Replace tf_record_iterator with a non-deprecated way to read TFRecords #1711tf.compat.v1.train.summary_iterator
- should become our own wrapper of tf_record_iterator for the places we need it (only tests)tf.compat.v1.pywrap_tensorflow.PyRecordReader_New
-> converted to be only a legacy fallback for when we can't usetf.compat.v1.io.tf_record_iterator
The text was updated successfully, but these errors were encountered: