Category: Tensorflow

Jupyter notebook stuck at plotting a tensor (Tensorflow 2) using matplotlib (CPU going 100%)

Query asked by user I’m following a video tutorial and using matplotlib to plot a tensorflow tensor in a Jupyter Notebook. The cell just stuck and one CPU went 100%. import tensorflow as tf import tensorflow_probability as tfp tfd = tfp.distributions tfb = tfp.bijectors import matplotlib.pyplot as plt # %matplotlib inline normal = tfd.Normal(loc=0, scale=1) […]

Get character out of image with python

Query asked by user I want to detect the characters in a image like this with python: In this case the code should return the result ‘6010001’. How can I get the result out of this image? What do I need? For your information, if the solution is a AI-solution, there are about 20.000 labeled […]

Slow ResNet50 training time using AWS Sagemaker GPU instance

Query asked by user I am trying to train a ResNet50 model using keras with tensorflow backend. I’m using a sagemaker GPU instance ml.p3.2xlarge but my training time is extremely long. I am using conda_tensorflow_p36 kernel and I have verified that I have tensorflow-gpu installed. When inspecting the output of nvidia-smi I see the process […]

AttributeError: ‘MapDataset’ object has no attribute ‘preprocess’ in tensorflow_federated tff

Query asked by user I’m testing this tutorial with non-IID distribution for federated learning: https://www.tensorflow.org/federated/tutorials/tff_for_federated_learning_research_compression In this posted question TensorFlow Federated: How to tune non-IIDness in federated dataset? it suggested to use tff.simulation.datasets.build_single_label_dataset() as a way to produce a non-IID distribution for the dataset. I tried to apply that first (see the code) and got […]

broken tensorflow keras function

Query asked by user I have this function that used to work and broke when I updated or upgrade to tensorflow 2. def df_to_dataset(dataframe, shuffle=True, batch_size=32): dataframe = dataframe.copy() labels = dataframe.pop(‘SalePrice’) ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels)) if shuffle: ds = ds.shuffle(buffer_size=len(dataframe)) ds = ds.batch(batch_size) return ds batch_size = 32 train_ds = df_to_dataset(df_train, batch_size=batch_size) val_ds = […]

Multi-output losses keras/tensorflow do not behave as expected. Target #2 MAE loss is huge and >1 despite sigmoid activation and 0-1 scaled labels

Query asked by user SOLVED: see comment by Marco Cerliani. tl;dr Each output must be passed to the model as a separate array. I have a neural network with two different targets to estimate: Target #1 is 0-infinity, final single node dense layer uses ‘linear’ activation function. Target #2 is 0-1 scaled, final single node […]

How to add a layer in a functional tensorflow ResNet50 model?

Query asked by user I am building a image captioning model and for that I am using ResNet50 as a feature extraction model. I have written the code, and it is working properly: rs50 = tf.keras.applications.ResNet50(include_top = False, weights = ‘imagenet’, input_shape = (224, 224, 3)) new_input = rs50.input hidden_layer = rs50.layers[-1].output feature_extract = tf.keras.Model(new_input, […]

Tensorflow: How to slice/gather all possible configurations?

Query asked by user I have a tensor with shape (batch size, sequence length, 2, N, K) (in my particular case, the 2 represents the (x, y) spatial position). N represents N variables and K is the number of values each variable can take. I want to generate a tensor with shape (batch size, sequence […]