I have seen an implementation of inverting Gradients in Tensorflow here but it uses Graphs and no eager exection: How to implement inverting gradient in Tensorflow? I am struggerling in the Implementation and asking for help. How would this look in Tensorflow with eager exection/GradientTape? Thank you! Source: Python-3x..

#### Category : eager-execution

When I’m testing my tensorflow keras custom loss(using additional input data to calculate loss), which is as follow: @tf.function def build_walker_loss(labeled_output_t, unlabeled_output_t, label): similarity = tf.matmul(labeled_output_t, unlabeled_output_t, transpose_b=True) transition_prob_to_unlabeled = tf.nn.softmax(similarity, name="transition_prob_to_unlabeled") transition_prob_to_labeled = tf.nn.softmax(tf.transpose(similarity), name="transition_prob_to_labeled") roundtrip_prob = tf.matmul(transition_prob_to_unlabeled, transition_prob_to_labeled, name="roundtrip_prob") label = tf.reshape(label, [-1, 1]) target_distribution = tf.cast(tf.equal(label, tf.transpose(label)),dtype=tf.float32) num_class = tf.compat.v1.reduce_sum(target_distribution, axis=1, keep_dims=True) ..

Take this function which just returns the value of a tensor: def foo(input): return tf.keras.backend.get_value(input) I we have a dataset, trying to call dataset = dataset.map(lambda input,target: (foo(input),target)) will result in an error because it is not possible to access numpy of a tensor when calling .map. So I used tf.py_function. And using dataset = ..

I have TensorFlow 2.6 installed with Python 3.9. However, I get the following errors: tf.enable_eager_execution() AttributeError: module ‘tensorflow’ has no attribute ‘enable_eager_execution’ When I run tf.executing_eagerly() I get False. I reinstalled TensorFlow and I’m still getting the same errors. Source: Python..

I am trying to write a function which is a part of tfx (Tensorflow Extended) Transform component. I want to use some tf.Transform module (note its something different than tfx Transform component) functions inside. This is my first time with Tensoflow, so I’d love to debug and see the result of each line of code ..

I have built a custom keras model and during its forward pass, it uses the output of a function from another library. However, the parameter to this function must be a numpy array. During model.compile() I can set the run_eagerly parameter to True, then I can convert the output from forward pass to numpy by ..

The code snippet below is a vanila implementation of a TensorFlow model in which I am using subclass model and a custom fit function (implemented through train_step and test_step). The code works fine in the eager execution mode (default mode of execution in TF2.0) but fails in the graph mode. import numpy as np import ..

I want to save a tensorflow variable of type tensorflow.python.framework.ops.Tensor as a .npy file while eager execution is disabled. Now this works absolutely fine with eager execution enabled if I simply do tfvar.numpy() and then save it as .npy but it doesn’t work with if eager execution is disabled. Is there any way to do ..

I need to compute tf.Variable gradients in a class method, but use those gradients to update the variables at a later time, in a different method. I can do this when not using the @tf.function decorator, but I get the TypeError: An op outside of the function building code is being passed a "Graph" tensor ..

I am defining a custom layer as the last one of my network. Here I need to convert a tensor, the input one, into a numpy array to define a function on it. In particular, I want to define my last layer similarly to this: import tensorflow as tf def hat(x): A = tf.constant([[0.,-x[2],x[1]],[x[2],0.,-x[0]],[-x[1],x[0],0.]]) return ..

## Recent Comments