Category : eager-execution

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..

Read more

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) ..

Read more

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 = ..

Read more

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 ..

Read more

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 ..

Read more

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 ..

Read more