Categories
Misc

How do I slove this error?

I was doing an exercise by google dev’s ml tensorflow course. Im getting this error:

File “c:UsersshivaDocumentsAI_ML_TensorflowTensorflowEx2MNISTComputerVision.py“, line 24, in <module>

model.fit(x_train, y_train, epochs=5)

TypeError: Expected uint8, but got 1e-07 of type ‘float’.

———————————————————————————————————————————————

Here is the code:

# YOUR CODE SHOULD START HERE
# YOUR CODE SHOULD END HERE
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
# YOUR CODE SHOULD START HERE
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation=tf.nn.relu),

tf.keras.layers.Dense(10, activation=tf.nn.softmax)])
# YOUR CODE SHOULD END HERE
model = tf.keras.models.Sequential([
# YOUR CODE SHOULD START HERE

# YOUR CODE SHOULD END HERE
])
model.compile(optimizer = tf.keras.optimizers.Adam(),
loss = ‘sparse_categorical_crossentropy’,
metrics=[‘accuracy’])
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)
# YOUR CODE SHOULD START HERE
# YOUR CODE SHOULD END HERE

———————————————————————————————————————————————

I dunno what shud I do? I checked my code but can’t find anything that might cause the error. I asked the same question on the r/learnmachinelearning but got no response, Pls help!

submitted by /u/StarLan7
[visit reddit] [comments]

Categories
Misc

Any open source TensorFlow training orchestrator /dashboard?

hello r/tensorflow. As a backend engineer, I am very unfamiliar with tensorflow and ML in general, so please forgive me if this question seems unreasonable to you.

Because of the need of my lab, I’ve been looking for a solution for tensorflow orchestration. We have one server with a powerful GPU, and several users who want to run their tensorflow jobs on that powerful GPU. Instead of making schedules offline and individually log in to the server, is there any open source project I can deploy to the server that serves as an orchestrator?

For example, it provides a simple WebUI to let the user upload their job and all necessary files. Then the user submits the job to add it to a queue, which will run when it’s the first in the line. It will also report the progress and the result of the job.

I think there should be some kind of open-sourced project out there that fits this need, but I haven’t found it yet. So please help.

submitted by /u/xcsublime
[visit reddit] [comments]

Categories
Misc

How to disable exceptions encountered when calling Lambda layer?

I’m experimenting with some logic before creating a custom keras layer, but my Lambda layer isn’t allowing me to check the output shape with model.summary(). It says:

ValueError: Exception encountered when calling layer “Lambda_1” (type Lambda).

The following Variables were created within a Lambda layer (Lambda_1)

but are not tracked by said layer:

<tf.Variable ‘Lambda_1/map/while/RGAT_1/edge_type_0/kernel:0’ shape=(7, 10) dtype=float32>

<tf.Variable ‘Lambda_1/map/while/RGAT_1/edge_type_0/Edge_attention_parameters_0:0’ shape=(5, 4) dtype=float32>

The layer cannot safely ensure proper Variable reuse across multiple

calls, and consquently this behavior is disallowed for safety. Lambda

layers are not well suited to stateful computation; instead, writing a

subclassed Layer is the recommend way to define layers with

Variables.

Is there a way to temporally disable this behavior? 🤔

submitted by /u/jorvan758
[visit reddit] [comments]

Categories
Misc

The Official Feedback and Discussion Thread

Here you can discuss anything that doesn’t require its own post

submitted by /u/TheNASAguy
[visit reddit] [comments]

Categories
Misc

Could you help to combine input layers with a specific NamedTuple class?

Hello, I’ve been searching/reading for a fair amount of hours, but I’m pretty much stuck with this problem.

This is my code:

from typing import NamedTuple class MessagePassingInput(NamedTuple): node_embeddings: tf.Tensor adjacency_lists: Tuple[tf.Tensor, ...] from keras import Model, layers import tensorflow as tf inputLayer_X = layers.Input(shape=tf.TensorShape(dims=(None, 7)),name="Input_X") inputLayer_A1 = layers.Input(shape=tf.TensorShape(dims=(None, 2)),name="Input_A1", dtype=tf.int32) inputLayer_A2 = layers.Input(shape=tf.TensorShape(dims=(None, 2)),name="Input_A2", dtype=tf.int32) inputLayer_A3 = layers.Input(shape=tf.TensorShape(dims=(None, 2)),name="Input_A3", dtype=tf.int32) 

And I would like that every entry in those inputs ends up in a next layer more or less like this: newLayer = [MessagePassingInput(inputLayer_X[i], [inputLayer_A1[i], inputLayer_A2[i], inputLayer_A3[i]]) for i in range(len(inputLayer_X))]. However, I’m just not being able to find how (I have tried with tf.map_fn and layers.Lambda, but wasn’t able to feed all those input layers and use the function in order)

If you could help me, I would be very grateful 🙏

submitted by /u/jorvan758
[visit reddit] [comments]

Categories
Misc

Wrap up of Advent of Code 2021 in pure TensorFlow

Wrap up of Advent of Code 2021 in pure TensorFlow submitted by /u/pgaleone
[visit reddit] [comments]
Categories
Misc

How to call predict() in eager mode (tf1 and tf2 compatibility issues)

I’m trying to perform an adversarial attack using [this demo] on my detection model created with tensorflow/keras. The problem is that the script I’m trying to use was written with TF1 in mind, whereas I’ve created my model with TF2.

When I feed my model into the script I’m seeing the following error:

ValueError: Calling `Model.predict` in graph mode is not supported when the `Model` instance was constructed with eager mode enabled. Please construct your `Model` instance in graph mode or call `Model.predict` with eager mode enabled.

I’ve already learned that this is because different TF versions used different modes by default. Could you give me a tip on what can I do to convert my model to the fitting mode?

submitted by /u/Piotrek1
[visit reddit] [comments]

Categories
Misc

Custom loss with images

Hi everyone, probably this is a silly question but I will appreciate if someone takes the time to answer it please.

I’m trying to build a custom loss function, and for now as a dummy I’m just trying to build a MSE function and compare it with the in-built MSE.

My code is just an autoencoder that receives 2D images with a batch size of 128, so when verify y_true I obtain a tensor like this: [128, 256, 256] where the 128 is batch size and the other two are the dimensions.

So, when I was looking for the MSE custom loss and compared it with the in-built one, I realised that they’re doing something like this:

diff = math_ops.squared_difference(y_pred, y_true) loss = K.mean(diff, axis=-1) loss = loss/10 

Then I get a vector as a loss function as this: [128,256], so my question is: is this right? shouldn’t loss be an scalar value instead of a vector?, should I use the whole 3D tensor instead of only 2 components in the 2nd line?

I’m kinda lost and since I don’t understand this I cannot move forward on my project.

submitted by /u/DaSpaceman245
[visit reddit] [comments]

Categories
Misc

Training Custom TFDS Dataset

Hi, I am working on a classification task for audio data with a custom dataset. i am trying to use the leaf audio github on my own dataset, which runs on the speech commands tfds dataset. i created my own tfds dataset for my custom data, following the exact same setup as the speech commands data. however, i am running into an issue as the dataset is stored in the PrefetchDataset format, and I do not know how to access the data for model.fit . i have researched ways to fix this error and the solutions have not worked, so i was wondering if anyone would be able to help me

submitted by /u/Kunnanada
[visit reddit] [comments]

Categories
Misc

Scientists Develop 3D Simulation of a Living Cell

Researchers from the University of Illinois at Urbana-Champaign developed GPU-accelerated software to simulate a 2-billion-atom cell that metabolizes and grows like a living cell.