tensorflow

ValueError: in user code: ValueError: No gradients provided for any variable for Autoencoder Tensorflow

ValueError: in user code: ValueError: No gradients provided for any variable for Autoencoder Tensorflow Question: I have the above code and I have the below error during my fit ValueError: No gradients provided for any variable: ([‘dense_12/kernel:0’, ‘dense_12/bias:0’, ‘dense_13/kernel:0’, ‘dense_13/bias:0’],). Provided grads_and_vars is ((None, <tf.Variable ‘dense_12/kernel:0’ shape=(784, 2) dtype=float32>), (None, <tf.Variable ‘dense_12/bias:0’ shape=(2,) dtype=float32>), (None, …

Total answers: 1

TypeError: Unhashable type: 'numpy.ndarray' in keras

TypeError: Unhashable type: 'numpy.ndarray' in keras Question: I have a code below while True: question = input("你: ") question_seq = tokenizer.texts_to_sequences([question]) question_seq_padded = keras.preprocessing.sequence.pad_sequences(question_seq, maxlen=max_len) answer_seq = model.predict(question_seq_padded).argmax(axis=-1)[0] answer = tokenizer.index_word[answer_seq] print("機器人:", answer) And when i ran it, happened some wrong answer = tokenizer.index_word[answer_seq] issued error TypeError: Unhashable type: ‘numpy.ndarray’ I try to find the …

Total answers: 2

TensorFlow results are not reproducible despite using tf.random.set_seed

TensorFlow results are not reproducible despite using tf.random.set_seed Question: According to a tutorial on Tensorflow I am following, the following code is supposed to give reproducible results, so one can check if the exercise is done correctly. Tensorflow version is 2.11.0. import tensorflow as tf import numpy as np class MyDenseLayer(tf.keras.layers.Layer): def __init__(self, n_output_nodes): super(MyDenseLayer, …

Total answers: 1

Tensorflow M2 Pro Failure

Tensorflow M2 Pro Failure Question: When I run the following test script for tensorflow import tensorflow as tf cifar = tf.keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar.load_data() model = tf.keras.applications.ResNet50( include_top=True, weights=None, input_shape=(32, 32, 3), classes=100,) loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"]) model.fit(x_train, y_train, epochs=5, batch_size=4) I obtain the following terminal output: Metal device set …

Total answers: 1

Tensorflow using all of one GPU but little of the other

Tensorflow using all of one GPU but little of the other Question: After running into OOM errors using Tensorflow Object Detection API with an NVIDIA 3080 (10GB) I bought a 4090 (24GB). I am currently running both together, but I noticed that in high batch size runs, I’m using almost all the 3080 but varying …

Total answers: 1

Reshape tensors of unknown shape with tf.function

Reshape tensors of unknown shape with tf.function Question: Let’s say that in my function I have to deal with input tensors of shape [4,3,2,1] and [5,4,3,2,1]. I want to reshape them in such a way that the last two dimensions are swapped, e.g., to [4,3,1,2]. In eager mode this is easy, but when I try …

Total answers: 1

Torchserve custom handler – how to pass a list of tensors for batch inferencing

Torchserve custom handler – how to pass a list of tensors for batch inferencing Question: I am trying to create a custom handler in torchserve and want to also use torchserve’s batch capability for parallelism for optimum use of resources. I am not able to find out how to write custom handler for this inference. …

Total answers: 1

Class imported from a local module cannot find the definition of a variable declared in the same module, Python

Class imported from a local module cannot find the definition of a variable declared in the same module, Python Question: I have this piece of code defined in the model_utils.py local module. import os os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘3’ os.environ["SM_FRAMEWORK"] = "tf.keras" import segmentation_models as sm import matplotlib.pyplot as plt import tensorflow_io as tfio import tensorflow as …

Total answers: 1

How to make inference from a model using Lambda?

How to make inference from a model using Lambda? Question: I trained an image segmentation model with Mask-RCNN and my goal now is to make inference using AWS Lambda, for this I am modifying the Deploy multiple machine learning models for inference on AWS Lambda and Amazon EFS, my project tree is: . ├── Dockerfile …

Total answers: 1

tf.keras.utils.get_file error: TypeError: '<' not supported between instances of 'int' and 'NoneType'

tf.keras.utils.get_file error: TypeError: '<' not supported between instances of 'int' and 'NoneType' Question: everyone, Recently I start to program with tensorflow 2.10.0, have the following codes in my ipynb file (Jupyter Notebook file): if not data_dir.exists(): tf.keras.utils.get_file(‘free-spoken-digit-dataset-master.zip’,origin="https://codeload.github.com/Jakobovski/free-spoken-digit-dataset/zip/refs/heads/master",extract=True,cache_dir=’.’,cache_subdir=’data’) I want to download the file free-spoken-digit-dataset-master.zip from the URL https://codeload.github.com/Jakobovski/free-spoken-digit-dataset/zip/refs/heads/master, after running the codes the following error …

Total answers: 2