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

Shape mismatch: inputs 32 != attn_output 1024 #89

Open
code-Kasim opened this issue Oct 13, 2024 · 0 comments
Open

Shape mismatch: inputs 32 != attn_output 1024 #89

code-Kasim opened this issue Oct 13, 2024 · 0 comments

Comments

@code-Kasim
Copy link

I am done trying to resolve it but couldn't do the thing, if anyone can help it would be a great support, i am trying to run it for generating IR images through my custom dataset(2562563). But ended up here..after being stuck for almost a month...will add my modified code files and here is the error message: ##############
TransGAN Train
##############

Depth list: [5, 4, 3, 2, 1, 1]
Length of depth list: 6
Heads list: [4, 4, 4, 4, 4, 4]
Length of heads list: 6
MLP dim list: [4096, 2048, 1024, 512, 256, 128]
Length of MLP dim list: 6
Initializing model from scratch

batch_size : 32
noise_dim : 256
g_dim : 1024
g_depth : [5, 4, 3, 2, 1, 1]
g_heads : [4, 4, 4, 4, 4, 4]
g_mlp : [4096, 2048, 1024, 512, 256, 128]
g_initializer : orthogonal
g_learning_rate : 0.0001
g_beta_1 : 0.0
g_beta_2 : 0.99
d_dim : [512, 256, 128]
d_depth : [2, 3]
d_heads : [4, 4, 4]
d_mlp : [2048, 1024, 1024, 1024]
d_initializer : orthogonal
d_patch_size : 16
d_learning_rate : 0.0001
d_beta_1 : 0.0
d_beta_2 : 0.99
d_steps : 1
loss : wgan
gp_weight : 10.0
policy : color,translation,cutout

<class 'keras.src.metrics.reduction_metrics.Mean'>
patches shape: (32, 1024, 1024)
pos_embeddings shape: (1, 1024, 1024)
patches shape: (32, 1024, 1024)
pos_embeddings shape: (1, 1024, 1024)
patches shape: (32, 1024, 1024)
pos_embeddings shape: (1, 1024, 1024)
Traceback (most recent call last):
File "/home/user/kasim/TransGAN-main(1)/train.py", line 252, in
main()
File "/home/user/kasim/TransGAN-main(1)/train.py", line 232, in main
run_training(args)
File "/home/user/kasim/TransGAN-main(1)/train.py", line 195, in run_training
train_step(image_batch)
File "/home/user/anaconda3/envs/transgan/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/tmp/autograph_generated_filexagp5mu3.py", line 63, in tf__train_step
ag
.for_stmt(ag__.converted_call(ag__.ld(range), (ag__.ld(hparams)['d_steps'],), None, fscope), None, loop_body, get_state_1, set_state_1, (), {'iterate_names': '_'})
File "/tmp/autograph_generated_filexagp5mu3.py", line 28, in loop_body
generator_output = ag
.converted_call(ag__.ld(generator), (ag__.ld(noise),), dict(training=True), fscope)
File "/home/user/anaconda3/envs/transgan/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/user/kasim/TransGAN-main(1)/model.py", line 230, in call
x = self.block_8(x, training=training)
File "/home/user/kasim/TransGAN-main(1)/model.py", line 143, in build
raise ValueError(f"Shape mismatch: inputs {input_shape[-1]} != attn_output {attn_output_shape[-1]}")
ValueError: in user code:

File "/home/user/kasim/TransGAN-main(1)/train.py", line 146, in train_step  *
    generator_output = generator(noise, training=True)
File "/home/user/anaconda3/envs/transgan/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler  **
    raise e.with_traceback(filtered_tb) from None
File "/home/user/kasim/TransGAN-main(1)/model.py", line 230, in call
    x = self.block_8(x, training=training)
File "/home/user/kasim/TransGAN-main(1)/model.py", line 143, in build
    raise ValueError(f"Shape mismatch: inputs {input_shape[-1]} != attn_output {attn_output_shape[-1]}")

ValueError: Exception encountered when calling Generator.call().

Shape mismatch: inputs 32 != attn_output 1024

Arguments received by Generator.call():
  • z=tf.Tensor(shape=(32, 256), dtype=float32)
  • training=True

frame_00023
will share code files if needed..thank in advance and waiting eagerly!!!

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

No branches or pull requests

1 participant