Comments (8)
@sachinprasadhs help me out
from keras.
Could you please provide reproducible code in a colab Gist to understand more on the issue. Thanks!
from keras.
@sachinprasadhs yeaa
https://colab.research.google.com/drive/1QyLNRMwOhuMpZ_4_eJ5m3pKh2Np_wG7g?usp=sharing
from keras.
You are restricting the input_shape
for each convolution operation to be 128,128,3
, which does not fit to the actual data size which you are passing which is 256,256,3
, replacing your code with below code should work.
from keras.layers import Dense, Conv2D, MaxPool2D, Flatten
from keras.models import Sequential
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=3, padding="same", activation="relu",input_shape=[256,256,3]))
model.add(Conv2D(filters=32, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=128, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=128, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=256, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=256, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Flatten())
model.add(Dense(units = 1024, activation="relu"))
model.add(Dense(units = 1024, activation="relu"))
model.add(Dense(units = 38, activation="softmax"))
model.compile(optimizer = "adam", loss ='categorical_crossentropy', metrics=['accuracy'])
from keras.
history = model.fit(x=training_set, validation_data=validation_set, epochs=10)
ValueError Traceback (most recent call last)
Cell In[12], line 1
----> 1 history = model.fit(x=training_set, validation_data=validation_set, epochs=10)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/keras/src/utils/traceback_utils.py:123, in filter_traceback..error_handler(*args, **kwargs)
120 filtered_tb = _process_traceback_frames(e.traceback)
121 # To get the full stack trace, call:
122 # keras.config.disable_traceback_filtering()
--> 123 raise e.with_traceback(filtered_tb) from None
124 finally:
125 del filtered_tb
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/keras/src/backend/tensorflow/nn.py:546, in categorical_crossentropy(target, output, from_logits, axis)
540 raise ValueError(
541 "Arguments target
and output
must be at least rank 1. "
542 "Received: "
543 f"target.shape={target.shape}, output.shape={output.shape}"
544 )
545 if len(target.shape) != len(output.shape):
--> 546 raise ValueError(
547 "Arguments target
and output
must have the same rank "
548 "(ndim). Received: "
549 f"target.shape={target.shape}, output.shape={output.shape}"
550 )
551 for e1, e2 in zip(target.shape, output.shape):
552 if e1 is not None and e2 is not None and e1 != e2:
ValueError: Arguments target
and output
must have the same rank (ndim). Received: target.shape=(None,), output.shape=(None, 38)
still i get the error dude! :(
from keras.
It is basically the number of classes you are using, if the data is a binary classification then you need to change the output layer to something like model.add(Dense(units = 1, activation="sigmoid"))
from keras.
Thank you so much bro solved
from keras.
Are you satisfied with the resolution of your issue?
Yes
No
from keras.
Related Issues (20)
- Keras deserialization Object Error - from keras.saving.legacy.serialization import deserialize_keras_object ImportError: cannot import name 'deserialize_keras_object' from HOT 4
- ML model is predicting the same output for different inputs HOT 4
- AttributeError: 'KerasHistory' object has no attribute 'layer' HOT 3
- Inconsistent handling of the loss from `add_loss` between jax and other backends HOT 3
- [Contribution Idea] Support OpenVINO as a backend in Keras 3 HOT 3
- Embedding(trainable=False) not working with Keras 3 HOT 1
- Conversion of symbolic tf.Tensor HOT 4
- keras with pytorch backend and mps set to default should use an mps generatir in randperm HOT 13
- Keras with TF backend GaussianDropout gives error with mixed_bfloat16 HOT 3
- Loading model Conv2DTranspose from h5 file results in error complaining about group:1 parameter HOT 11
- [Bug] Custom evaluation don't work in torch (but work in tensorflow). HOT 4
- [bug] keras issue on tpu-vm HOT 3
- How to import existing trained pytorch model to keras 3 HOT 2
- Any plan to add type annotations? HOT 2
- Add AdamWScheduleFree HOT 2
- Support `rar` archive file format extraction in keras.utils.get_file HOT 2
- AttributeError: 'types.SimpleNamespace' object has no attribute 'get_registered_object' from return keras.saving.get_registered_object(config["registered_name"]) in keras_nlp\src\utils\preset_utils.py HOT 4
- A checker is needed in Conv layers HOT 3
- Keras 3 / TF SavedModel export issues HOT 3
- tf.keras.utils.plot_model no longer supports layers with list as output HOT 4
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 keras.