tensorflow2.0

Why does my model work with `tf.GradientTape()` but fail when using `keras.models.Model.fit()`

白昼怎懂夜的黑 提交于 2020-03-23 12:03:53
问题 After much effort, I managed to build a tensorflow 2 implementation of an existing pytorch style-transfer project. Then I wanted to get all the nice extra features that are available through Keras standard learning, e.g. model.fit() . But the same model fails when learning through model.fit() . The model seems to learn the content features, but is unable to learn style features. This is the diagram of the model in quesion: def vgg_layers19(content_layers, style_layers, input_shape=(256,256,3)

Saving a TF2 keras model with custom signature defs

感情迁移 提交于 2020-03-21 17:59:50
问题 I have a Keras (sequential) model that could be saved with custom signature defs in Tensorflow 1.13 as follows: from tensorflow.saved_model.utils import build_tensor_info from tensorflow.saved_model.signature_def_utils import predict_signature_def, build_signature_def model = Sequential() // with some layers builder = tf.saved_model.builder.SavedModelBuilder(export_path) score_signature = predict_signature_def( inputs={'waveform': model.input}, outputs={'scores': model.output}) metadata =

Evaluating TF model inside a TF op throws error

半世苍凉 提交于 2020-03-21 12:23:43
问题 I am using TensorFlow 2. I am trying to optimize a function which uses the loss of a trained tensorflow model (poison). @tf.function def totalloss(x): xt = tf.multiply(x, (1.0 - m)) + tf.multiply(m, d) label = targetlabel*np.ones(xt.shape[0]) loss1 = poison.evaluate(xt, label, steps=1) loss2 = tf.linalg.norm(m, 1) return loss1 + loss2 I am not able to execute this function, however, when I comment the @tf.function line the function works! I need to use this function as a tensorflow op so as

Error occurred when finalizing GeneratorDataset iterator: Cancelled: Operation was cancelled

非 Y 不嫁゛ 提交于 2020-03-19 05:59:52
问题 While running kubeflow pipeline having code that uses tensorflow 2.0. below error is displayed at end of each epoch W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Cancelled: Operation was cancelled Also, after some epochs, it does not show log and shows this error This step is in Failed state with this message: The node was low on resource: memory. Container main was using 100213872Ki, which exceeds its request of 0.

How to install the latest version of TensoFlow 2?

寵の児 提交于 2020-03-16 06:38:12
问题 I am wondering that why I cannot install the TensorFlow 2.0.0 (stable version until now in their official website even in PyPi) I used to had the TensorFlow 2.0.0b1 version, but I was dealing with several warnings because my numpy version wasn't compatible with the TensorFlow. It was 1.17 and must be 1.16.4 (Reference). Hence, I downgrade it but TensorFlow didn't work anymore. So I decide to reinstall the TensorFlow latest stable version as mentioned above. Here is I've done so far: pip

States argument missing in custom Model using custom RNN layer

安稳与你 提交于 2020-03-03 09:59:27
问题 I'm building my own layer in Tensorflow 2.1 and using it in custom model. In the example below I copied MinimalRNNCell code from tensorflow website (https://www.tensorflow.org/api_docs/python/tf/keras/layers/RNN) and I'm trying to use this layer in my model. However, when trying to fit the model I'm getting an error saying that call method of a cell requires "states" argument and I'm not providing it. How should I correct my model to provide that argument? My code: import tensorflow as tf

Tensorflow 2.0 : frozen graph support [closed]

送分小仙女□ 提交于 2020-02-24 04:13:51
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 20 days ago . Will the support for frozen graph continue in tensorflow 2.0 or deprecated? I mean the scripts and APIs to create/optimize frozen graph from saved_model. Also the APIs to run the inference for the same. Assuming it will be supported in future, what is the recommended method

Keras inconsistent prediction time

限于喜欢 提交于 2020-02-23 10:37:13
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. ga97dil wants to draw more attention to this question: “The bounty will be awarded to the one who can explain why the problem arises and whether it is a bug in tensorflow/keras or not.” I tried to get an estimate of the prediction time of my keras model and realised something strange. Apart from being fairly fast normally, every once in a while the model needs quite long to come up with a

Keras inconsistent prediction time

余生长醉 提交于 2020-02-23 10:36:13
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. ga97dil wants to draw more attention to this question: “The bounty will be awarded to the one who can explain why the problem arises and whether it is a bug in tensorflow/keras or not.” I tried to get an estimate of the prediction time of my keras model and realised something strange. Apart from being fairly fast normally, every once in a while the model needs quite long to come up with a

TFF: Invalid argument: Default MaxPoolingOp only supports NHWC on device type CPU

≯℡__Kan透↙ 提交于 2020-02-16 09:52:55
问题 Here is part of my code TFF for item in data_root.glob("*"): print(item.name) CLASS_NAMES = np.array([item.name for item in data_root.glob('*')]) def get_label(file_path): parts = tf.strings.split(file_path, os.path.sep) return parts[-2] == CLASS_NAMES IMG_WIDTH = 200 IMG_HEIGHT = 200 def decode_img(img): img = tf.io.decode_jpeg(img, channels=3) img = tf.image.convert_image_dtype(img, tf.float32) return tf.image.resize(img, [IMG_HEIGHT, IMG_WIDTH]) def process_path(file_path): label = get