Tensoflow 2.12.0 does not recognize tensorflow.compiler.xla.experimental

Using the Bert code, I see this import line: from tensorflow.compiler.xla.experimental.xla_sharding import xla_sharding which causes this error: ModuleNotFoundError: No module named ‘tensorflow.compiler.xla.experimental’ Below you can see the versions and packages I have installed: $ pip list | grep tensorflow tensorflow 2.12.0 tensorflow-addons 0.20.0 tensorflow-estimator 2.12.0 tensorflow-io-gcs-filesystem 0.32.0 $ find python3.8/site-packages/ -name compiler python3.8/site-packages/google/protobuf/compiler python3.8/site-packages/tensorflow/python/compiler python3.8/site-packages/tensorflow/xla_aot_runtime_src/tensorflow/compiler… Read More Tensoflow 2.12.0 does not recognize tensorflow.compiler.xla.experimental

Tensorflow: dataset or model is in wrong shape

I want to do some image processing. To do so, I put in an image and get back another one (a mask) For testing, my dataset consists of only one image and its mask: train_data = tf.data.Dataset.from_tensors((img, mask)) both are of shape (720, 1280, 3). I tried using a simple model: model = tf.keras.Sequential([ tf.keras.layers.experimental.preprocessing.Rescaling(1./255,… Read More Tensorflow: dataset or model is in wrong shape

how to calculate the average of elements above a certain threshold in tensorflow

So i want to calculate the mean of the elements that are greater than a fixed threshold (threshold=0.8). Task in numpy : X = np.array([[0.11,0.99,0.70]]) print(np.nanmean(X[X>0.8])) Out : 0.99 What is the equivalent in tensorflow without converting the tensor ‘c’ to a numpy array? Exmp : c = tf.constant([[0.11,0.99,0.70]]) tf.reduce_mean(tf.where(tf.greater(c,(tf.constant(0.8, dtype=tf.float32))))) the output is equal… Read More how to calculate the average of elements above a certain threshold in tensorflow

Tensorflow: tf.cond, how to return multi dim tensors instead of simple values?

When I run my code: import tensorflow as tf import numpy as np A = np.array([ [0,1,0,1,1,0,0,0,0,1], [0,1,0,1,1,0,0,0,0,0], [0,1,0,1,0,0,0,0,0,1] ]) sliced = A[:, -1] bool_tensor = tf.math.equal(sliced, 0) with tf.compat.v1.Session() as tfs: print(‘run(bool_tensor) : ‘,tfs.run(bool_tensor)) print(tf.cond(bool_tensor, lambda: 999, lambda: -999)) I get: run(bool_tensor) : [False True False] ValueError: Shape must be rank 0 but is… Read More Tensorflow: tf.cond, how to return multi dim tensors instead of simple values?

How can I bring a HTML Image to the backend?

I have a middleware: export async function imageTagging(image){ console.log(image) const response = await axios.get(‘/api/tensorflow’, { image: image }); return response.data[0]; } which logs me (image): <img data-v-713aaf8f="" id="MLIMAGE" src="/img/Erdmännchen.b5f674c2.jpg" width="50%" crossorigin="anonymous" class="card-img-top embed-responsive-item" style="border-style: solid;"> my API-Call in the backend looks like: app.get(‘/api/tensorflow’, userMiddleware.isLoggedIn, (req, res) => { console.log(req.query); console.log(res.query); }) it logs me: {}… Read More How can I bring a HTML Image to the backend?

Why is this requests get not working with this url

If i run this Python code my program just hangs up. (I don`t get any error.) import requests url = "https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/generative/dcgan.ipynb&quot; r = requests.get(url) But this works perfectly fine as expected. import requests url = "https://stackoverflow.com&quot; r = requests.get(url) Using curl to get the github file worked also fine. curl https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/generative/dcgan.ipynb So can you reproduce… Read More Why is this requests get not working with this url