tf.keras

How to predict (multi) labeled datapoints?

How to predict (multi) labeled datapoints? Question: for example if I have 5 points and each point has dimension of 3 and has one of 10 possible labels from 0 to 9. Points XTrain: [[0.20861965 0.47901568 0.92075312], [0.96175914 0.70659989 0.82364516], [0.51805523 0.42727509 0.92545694], [0.4061363 0.55752676 0.56914541], [0.47859976 0.81323072 0.042954 ]] Labels y_true: [5 5 0 …

Total answers: 1

Is it possible to split a tensorflow dataset into train, validation AND test datasets when using image_dataset_from_directory?

Is it possible to split a tensorflow dataset into train, validation AND test datasets when using image_dataset_from_directory? Question: I am using tf.keras.utils.image_dataset_from_directory to load a dataset of 4575 images. While this function allows to split the data into two subsets (with the validation_split parameter), I want to split it into training, testing, and validation subsets. …

Total answers: 2

How to attach or get filenames from MapDataset from image_dataset_from_directory() in Keras?

How to attach or get filenames from MapDataset from image_dataset_from_directory() in Keras? Question: I am training convolutional autoencoder and I have this code for loading data (images): train_ds = tf.keras.preprocessing.image_dataset_from_directory( ‘path/to/images’, image_size=image_size ) normalization_layer = layers.experimental.preprocessing.Rescaling(1./255) def adjust_inputs(images, labels): return normalization_layer(images), normalization_layer(images) normalized_train_ds = train_ds.map(adjust_inputs) As I don’t need class labels but images itself as …

Total answers: 3

tf.keras.preprocessing.image_dataset_from_directory Value Error: No images found

tf.keras.preprocessing.image_dataset_from_directory Value Error: No images found Question: belos is my code to ensure that the folder has images, but tf.keras.preprocessing.image_dataset_from_directory returns no images found. What did I do wrong? Thanks. DATASET_PATH = pathlib.Path(‘C:\Users\xxx\Documents\images’) image_count = len(list(DATASET_PATH.glob(‘.\*.jpg’))) print(image_count) output = 2715 batch_size = 4 img_height = 32 img_width = 32 train_ds = tf.keras.preprocessing.image_dataset_from_directory( DATASET_PATH.name, validation_split=0.8, subset="training", …

Total answers: 2

How to remove training=True from the inbound nodes of a layer in an existing model?

How to remove training=True from the inbound nodes of a layer in an existing model? Question: Assuming there is a model given as an h5 file, i.e., I can not change the code building the model’s architecture: from tensorflow.keras.layers import Input, BatchNormalization from tensorflow.keras.models import Model inputs = Input(shape=(4,)) outputs = BatchNormalization()(inputs, training=True) model = …

Total answers: 2

ERROR:The first argument to `Layer.call` must always be passed

ERROR:The first argument to `Layer.call` must always be passed Question: I am using tf.keras version 2.5.0. I defined my sequence of layers for a regression problem as a function, to be wrapped using the KerasRegressor class. This was done to allow me to perform a RandomizedSearchCV. import os import tensorflow as tf import tensorflow_addons as …

Total answers: 2

Cannot use keras models on Mac M1 with BigSur

Cannot use keras models on Mac M1 with BigSur Question: I am trying to use Sequential model from keras of tensorflow. When I am executing following statement: model.fit(x_train, y_train, epochs=20, verbose=True, validation_data=(x_dev, y_dev), batch_size=10) I am getting following errors: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2) W tensorflow/core/platform/profile_utils/cpu_utils.cc:126] Failed to …

Total answers: 3

SHAP DeepExplainer with TensorFlow 2.4+ error

SHAP DeepExplainer with TensorFlow 2.4+ error Question: I’m trying to compute shap values using DeepExplainer, but I get the following error: keras is no longer supported, please use tf.keras instead Even though i’m using tf.keras? KeyError Traceback (most recent call last) in 6 # …or pass tensors directly 7 explainer = shap.DeepExplainer((model.layers[0].input, model.layers[-1].output), background) 8 …

Total answers: 1

ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine'

ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine' Question: I’m getting this error while loading the tensorflow addons library import tensorflow_addons as tfa ImportError: cannot import name ‘keras_tensor’ from ‘tensorflow.python.keras.engine’ Asked By: dpacman || Source Answers: This error is because you have incompatibility issues between your TensorFlow, Python and tensorflow-addons. Uninstall the tensorflow-addons and install the …

Total answers: 1