Comments (4)
@myh1234567
Could you please verify that all input data (x, y, etc.) passed to your model is of the correct type (tf.float32, tf.float64, etc.) as expected by the model's architecture and the loss function ? Also, in order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you!
from tensorflow.
@myh1234567 Could you please verify that all input data (x, y, etc.) passed to your model is of the correct type (tf.float32, tf.float64, etc.) as expected by the model's architecture and the loss function ? Also, in order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you!
the following is the code snippent,
import tensorflow as tf
import numpy as np
import scipy.sparse as sp
import keras
from keras.utils import to_categorical
physical_device = tf.config.list_physical_devices("GPU")
print("===================================== num gpu:", len(physical_device))
def convert_sparse_matrix_to_sparse_tensor(X) -> tf.SparseTensor:
""" Convert a scipy sparse matrix to a SparseTensor."""
coo = X.tocoo()
indices = np.mat([coo.row, coo.col]).transpose()
return tf.sparse.SparseTensor(indices, coo.data, coo.shape)
X_transformed_train_db = sp.rand(100, 1000, density=0.1, format='coo')
X_train_db = convert_sparse_matrix_to_sparse_tensor(X_transformed_train_db)
X_train_db = tf.sparse.reorder(X_train_db)
y_train_db = np.random.randint(0, 3, size=(100,)) # Let's assume 3 classes
y_train_db_ = to_categorical(y_train_db)
gpus = tf.config.list_logical_devices("GPU")
strategy = tf.distribute.MirroredStrategy(gpus)
with strategy.scope():
opti = keras.optimizers.Adam(learning_rate=0.0001)
input_dimension = X_transformed_train_db.shape[1]
model_db = keras.Sequential()
model_db.add(keras.layers.Dense(1000, kernel_initializer=keras.initializers.HeNormal(seed=1), activation='relu', input_dim=input_dimension))
model_db.add(keras.layers.Dropout(0.1))
model_db.add(keras.layers.Dense(500, kernel_initializer=keras.initializers.HeNormal(seed=2), activation='relu'))
model_db.add(keras.layers.Dropout(0.1))
model_db.add(keras.layers.Dense(200, kernel_initializer=keras.initializers.HeNormal(), activation='relu'))
model_db.add(keras.layers.Dropout(0.1))
model_db.add(keras.layers.Dense(y_train_db_.shape[1], kernel_initializer=keras.initializers.RandomNormal(mean=0.0, stddev=0.05, seed=4), activation='softmax'))
model_db.compile(optimizer=opti, loss='categorical_crossentropy',metrics=['accuracy'])
history_db = model_db.fit(X_transformed_train_db, y_train_db_, epochs=3)
tensorflow 2.16.1
keras 3.3.3
scipy 1.13.1
numpy 1.26.4
thank you
from tensorflow.
@myh1234567 ,
I tried to execute the code and faced the indentation errors. Could you please provide colab gist or the executable way. And also could you please confirm this issue is happening with tensorflow 2.15 as well because, 2.15 contains keras2.0 and 2.16 contains keras3.0. Thank you!
from tensorflow.
@myh1234567 , I tried to execute the code and faced the indentation errors. Could you please provide colab gist or the executable way. And also could you please confirm this issue is happening with tensorflow 2.15 as well because, 2.15 contains keras2.0 and 2.16 contains keras3.0. Thank you!
https://colab.research.google.com/gist/myh1234567/a83605d7c47314f6a9a5ced2807f4fde/63362.ipynb
from tensorflow.
Related Issues (20)
- The Flower_Classification_with_TFLite_Model_Maker.ipynb runs low on memory HOT 2
- 'Sequential' object has no attribute '_get_save_spec'. Did you mean: '_set_save_spec'? HOT 1
- TensorFlow Lite with iOS MTLBuffer doesn't support dynamic shape? HOT 2
- `tf.data.Dataset.from_tensor_slices` allocates GPU RAM HOT 3
- import tensorflow command gives error HOT 1
- CUDA Messages in TensorFlow 2.17.0 and tf-nightly HOT 6
- GPU delegate and NNAPIDelegate results diverging significantly for a transformer model HOT 1
- Module not found HOT 2
- Accuracy Drop Across TensorFlow Versions When Using Keras 3 Instead of Keras 2 HOT 3
- Inconsistent results from distributed training of models containing `TimeDistributed` or `SeparableConv2D` HOT 2
- A Digital Future for All Siifsiin 2.0: A Next-Generation Platform for an Empowered Humanity
- Should this be opened against Keras repo? HOT 1
- TFlite: GPU delegate: ability to limit amount of GPU memory used by TFlite?
- Tensorflow Dataset API continues to be broken, list_files no longer works HOT 7
- In the local server command line environment, TensorFlow is able to recognize and utilize the GPU. However, when attempting to use TensorFlow in a Jupyter Notebook through a remote VSCode connection to the same server, there is an issue with loading the GPU libraries. HOT 1
- wasm-ld: error: --shared-memory is disallowed by c_api.o because it was not compiled with 'atomics' or 'bulk-memory' features. HOT 6
- IntelliSence in VS Code - Keras module not found by the IDE but is present HOT 3
- Tensorflow distributed + DTensor approach for large outer product HOT 1
- `tf.data.Dataset.prefetch()` error with basic usage HOT 1
- TensorFlow embedded in esp32
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflow.