Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not run when using the official sample code for Keras3 #1898

Closed
z4668640 opened this issue Jul 26, 2024 · 1 comment · Fixed by #1905
Closed

Does not run when using the official sample code for Keras3 #1898

z4668640 opened this issue Jul 26, 2024 · 1 comment · Fixed by #1905
Assignees
Labels

Comments

@z4668640
Copy link

Issue Type

Documentation Bug

Source

binary

Keras Version

Keras 3.4.1

Custom Code

No

OS Platform and Distribution

Windows

Python version

3.12.4

GPU model and memory

Nvidia A3000

Current Behavior?

I got an error when using the official Keras3 instance code.
When I took the last step of training I got the following error:
AttributeError: 'list' object has no attribute 'shape'

Standalone code to reproduce the issue or tutorial link

Using the original code, no changes.
https://github.com/keras-team/keras-io/blob/master/guides/custom_train_step_in_torch.py

Relevant log output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 22
     15 gan = GAN(discriminator=discriminator, generator=generator, latent_dim=latent_dim)
     16 gan.compile(
     17     d_optimizer=keras.optimizers.Adam(learning_rate=0.0003),
     18     g_optimizer=keras.optimizers.Adam(learning_rate=0.0003),
     19     loss_fn=keras.losses.BinaryCrossentropy(from_logits=True),
     20 )
---> 22 gan.fit(dataloader, epochs=1)

File c:\Users\C\miniconda3\envs\learn100\Lib\site-packages\keras\src\utils\traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    119     filtered_tb = _process_traceback_frames(e.__traceback__)
    120     # To get the full stack trace, call:
    121     # `keras.config.disable_traceback_filtering()`
--> 122     raise e.with_traceback(filtered_tb) from None
    123 finally:
    124     del filtered_tb

Cell In[4], line 27
     25     real_images = real_images[0]
     26 # Sample random points in the latent space
---> 27 batch_size = real_images.shape[0]
     28 random_latent_vectors = keras.random.normal(
     29     shape=(batch_size, self.latent_dim), seed=self.seed_generator
     30 )
     32 # Decode them to fake images

AttributeError: 'list' object has no attribute 'shape'
Copy link

github-actions bot commented Aug 3, 2024

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants