tensorflow2.0

How to multiply Tensorflow arrays across specified indicies

How to multiply Tensorflow arrays across specified indicies Question: I would like to multiply two Tensorflow Arrays in a certain way as shown in the code below: import tensorflow as tf from tensorflow.keras import mixed_precision policy = mixed_precision.Policy(‘mixed_float16’) mixed_precision.set_global_policy(policy) print(‘Compute dtype: %s’ % policy.compute_dtype) print(‘Variable dtype: %s’ % policy.variable_dtype) a = tf.random.normal(shape=[1000, 1439]) b = …

Total answers: 1

model.predict throws ValueError: expected shape=(None, 64, 64, 3), found shape=(None, 64, 3)

model.predict throws ValueError: expected shape=(None, 64, 64, 3), found shape=(None, 64, 3) Question: I modeled the following convolutional neural network (CNN) using tensorflow within a google colab notebook: import tensorflow as tf PATCHSIZE = 64 # CNN model model = tf.keras.models.Sequential([ # Convolutional layer. Learn 32 filters using a 3×3 kernel tf.keras.layers.Conv2D(32, (3, 3), activation="relu", …

Total answers: 1

Tensorflow model not training if dense layer is used as starter layer

Tensorflow model not training if dense layer is used as starter layer Question: I am facing a weird problem. I am training my TF model using custom training loops. If I use only dense layers as my 1st layer, the model does not seem to train (I am using flattened MNIST dataset to train). If …

Total answers: 1

Error `Cannot import name 'wrappers' from 'tensorflow.python.keras.layers'`?

Error `Cannot import name 'wrappers' from 'tensorflow.python.keras.layers'`? Question: The code is giving the following error message Cannot import name ‘wrappers’ from ‘tensorflow.python.keras.layers’ – and ImportError: graphviz or pydot are not available. Even after installing the graphviz and pydot using the !apt-get -qq install -y graphviz && pip install pydot still not able to genrate model.png. …

Total answers: 2

Is advanced indexing available across n-dimensions in TensorFlow?

Is advanced indexing available across n-dimensions in TensorFlow? Question: In PyTorch, we can use standard Pythonic indexing to apply advanced indexing across n-dimensions. preds is a Tensor of shape [1, 3, 64, 64, 12]. a, b, c, d are 1-dimensional Tensors of the same length. In this instance that length is 9, but this is …

Total answers: 1

FileNotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ../Saved_Model/1variablesvariables

FileNotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ../Saved_Model/1variablesvariables Question: I am trying to build a image classifier API. Built the model using Google Colab becasue i dont have a GPU. Am using CPU and donwloaded the model into the API application. But get this error when i try to access my …

Total answers: 2

Cannot import tensorflow_text

Cannot import tensorflow_text Question: I have problem with importing tensorflow_text I tried importing like below two methods but none of them worked import tensorflow_text as text import tensorflow_text as tf_text My tensorflow version is 2.9.1 and python version is Python 3.7.13. I tried installing tensorflow_text using below two methods but none of them is working. …

Total answers: 3

Element wise multiplication of two list that are tf.Tensor in tensorflow

Element wise multiplication of two list that are tf.Tensor in tensorflow Question: What is the fastest way to do an element-wise multiplication between a tensor and an array in Tensorflow 2? For example, if the tensor T (of type tf.Tensor) is: [[0, 1], [2, 3]] and we have an array a (of type np.array): [0, …

Total answers: 3

How to replace tf.placeholder in eager execution

How to replace tf.placeholder in eager execution Question: I am using a tf1 code as a reference for developing a model. In the reference code, they used tf.placeholder to give input to the model and the code is class model(object): def __init__(self, lstm_size, batch_len, output_nodes, keep_prob, learning_rate=0.001): self.inputs_ = tf.compat.v1.placeholder(tf.float32, shape=[batch_len, None, 512], name=’lstm_inputs’) self.targets_ …

Total answers: 1