tensorflow2.0

SageMaker and TensorFlow 2.0

杀马特。学长 韩版系。学妹 提交于 2019-12-23 07:47:56
问题 What is the best way to run TensorFlow 2.0 with AWS Sagemeker? As of today (Aug 7th, 2019) AWS does not provide TensorFlow 2.0 SageMaker containers, so my understanding is that I need to build my own. What is the best Base image to use? Example Dockerfile? 回答1: Here is an example Dockerfile that uses the underlying SageMaker Containers library (this is what is used in the official pre-built Docker images): FROM tensorflow/tensorflow:2.0.0b1 RUN pip install sagemaker-containers # Copies the

SavedModel - TFLite - SignatureDef - TensorInfo - Get intermediate Layer outputs

狂风中的少年 提交于 2019-12-23 05:36:10
问题 I would like to get intermediate layers output of a TFLite graph. Something in the lines of below. Visualize TFLite graph and get intermediate values of a particular node? The above solution works on frozen graphs only. Since SavedModel is the preferred way of serializing the model in TF 2.0, I would like to have a solution with a saved model. I tried to pass --output_arrays for "toco" with savedModelDir as input. This is not helping. From the documentation, it looks like SignatureDefs in

AttributeError: module 'tensorflow' has no attribute 'gfile'

笑着哭i 提交于 2019-12-23 03:33:15
问题 I trained a simple mnist model with tensorflow 2.0 on Google Colab and saved it in the .json format. Click here to check out the Colab Notebook where I've written the code. Then on running the command !simple_tensorflow_serving --model_base_path="/" --model_platform="tensorflow" It is showing the error AttributeError: module 'tensorflow' has no attribute 'gfile' simple_tensorflow_serving helps in easily deploying trained tensorflow model into production. Versions I'm using: (1) TensorFlow - 2

Batch Normalization doesn't have gradient in tensorflow 2.0?

南笙酒味 提交于 2019-12-21 05:18:05
问题 I am trying to make a simple GANs to generate digits from the MNIST dataset. However when I get to training(which is custom) I get this annoying warning that I suspect is the cause of not training like I'm used to. Keep in mind this is all in tensorflow 2.0 using it's default eager execution. GET THE DATA(not that important) (train_images,train_labels),(test_images,test_labels) = tf.keras.datasets.mnist.load_data() train_images = train_images.reshape(train_images.shape[0], 28, 28, 1).astype(

Tensorflow 2.0 - AttributeError: module 'tensorflow' has no attribute 'Session'

梦想与她 提交于 2019-12-20 08:59:14
问题 When I am executing the command sess = tf.Session() in Tensorflow 2.0 environment, I am getting an error message as below: Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'tensorflow' has no attribute 'Session' System Information: OS Platform and Distribution: Windows 10 Python Version: 3.7.1 Tensorflow Version: 2.0.0-alpha0 (installed with pip) Steps to reproduce: Installation: pip install --upgrade pip pip install tensorflow==2.0.0-alpha0 pip

Tensorflow 2.0: AttributeError: Tensor.name is meaningless when eager execution is enabled

独自空忆成欢 提交于 2019-12-17 21:22:09
问题 Keep getting these errors with tensorflow 2.0. Is this supposed to work? import tensorflow as tf import numpy as np x = tf.constant(3.0) with tf.GradientTape() as t: t.watch(x) y = (x - 10) ** 2 opt = tf.optimizers.Adam() opt.minimize(lambda: y, var_list=[x]) 回答1: In the tape you only have to compute the forward pass the optimizer and the minize definition are not part of the forward pass, thus you have to remote them. Moreover, if you want to use the minimize method of the optimizer, you don

How to lock specific values of a Tensor in TensorFlow?

妖精的绣舞 提交于 2019-12-13 16:06:33
问题 I'm trying to apply the lottery ticket hypothesis to a simple neural network written in TensorFlow 2.0 (using the Keras interface) as seen below: net = models.Sequential() net.add(layers.Dense(256, activation="softsign", name="Dense0", bias_initializer="ones")) net.add(layers.Dense(128, activation="softsign", name="Dense1", bias_initializer="ones")) net.add(layers.Dense(64, activation="softsign", name="Dense2", bias_initializer="ones")) net.add(layers.Dense(32, activation="softsign", name=

Perform a RandomWalk step with Tensorflow Probability's RandomWalkMetropolis function

醉酒当歌 提交于 2019-12-13 04:39:11
问题 I am new to Tensorflow Probability and would like to do a RandomWalk Montecarlo simulation. Let's say I have tensor r that represents a state. I want the tfp.mcmc.RandomWalkMetropolis function to return a proposal for a new state r'. tfp.mcmc.RandomWalkMetropolis(r) >>> <tensorflow_probability.python.mcmc.random_walk_metropolis.RandomWalkMetropolis object at 0x14abed2185c0> Instead of the same state, or a slightly perturbed state only this RandomWalkMetropolis object is returned. The

Keras BatchNormalization only works for constant batch dim when axis=0?

断了今生、忘了曾经 提交于 2019-12-13 04:26:37
问题 The following code shows one way that works and the other that fails. The BatchNorm on axis=0 should not depend on the batchsize or if it does it should be explicitly stated as such in the docs. In [118]: tf.__version__ Out[118]: '2.0.0-beta1' class M(tf.keras.models.Model): import numpy as np import tensorflow as tf class M(tf.keras.Model): def __init__(self, axis): super().__init__() self.layer = tf.keras.layers.BatchNormalization(axis=axis, scale=False, center=True, input_shape=(6,)) def

Converting short tensorflow 1.13 script into tensorflow 2.0

走远了吗. 提交于 2019-12-13 03:36:59
问题 I am trying to learn the dynamics of tensorflow2.0 by converting my tensorflow1.13 script (below) into a tensorflow2.0 script. However I am struggling to do this. I think the main reason why I am struggling is because the examples of tensorflow2.0 I have seen train neural networks and so they have a model which they compile and fit . However in my simple example below I am not using a neural network so I can't see how to adapt this code to tensorflow2.0 (For example, how do I replace session?