question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Facing "RunTimeError" for Usage code

See original GitHub issue

Hello @lucidrains,

I have tried running the below code:

import torch
from imagen_pytorch import Unet, Imagen

unet1 = Unet(
    dim = 32,
    cond_dim = 512,
    dim_mults = (1, 2, 4, 8),
    num_resnet_blocks = 3,
    layer_attns = (False, True, True, True),
    layer_cross_attns = (False, True, True, True)
)

unet2 = Unet(
    dim = 32,
    cond_dim = 512,
    dim_mults = (1, 2, 4, 8),
    num_resnet_blocks = (2, 4, 8, 8),
    layer_attns = (False, False, False, True),
    layer_cross_attns = (False, False, False, True)
)

imagen = Imagen(
    unets = (unet1, unet2),
    image_sizes = (64, 256),
    timesteps = 1000,
    cond_drop_prob = 0.1
).cuda()

text_embeds = torch.randn(4, 256, 768).cuda()
text_masks = torch.ones(4, 256).bool().cuda()
images = torch.randn(4, 3, 256, 256).cuda()

for i in (1, 2):
    loss = imagen(images, text_embeds = text_embeds, text_masks = text_masks, unet_number = i)
    loss.backward()

images = imagen.sample(texts = [
    'a whale breaching from afar',
    'young girl blowing out candles on her birthday cake',
    'fireworks with blue and green sparkles'
], cond_scale = 3.)

images.shape # (3, 3, 256, 256)

After executing the above code I am facing the below error : RuntimeError: Expected weight to be a vector of size equal to the number of channels in input, but got weight of shape [256] and input of shape [4, 128, 8, 8]

I am getting this error for the below line: loss = imagen(images, text_embeds = text_embeds, text_masks = text_masks, unet_number = i)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
XiangfanLicommented, Jun 28, 2022

Thanks!

1reaction
lucidrainscommented, Jun 28, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Facing RUNTIME error SIGKILL in this code - Stack Overflow
The rules: rewrite small numbers from input to output. Stop processing input after reading in the number 42.
Read more >
Switching to Pulsar backend - facing runtime error #466 - GitHub
To solve the problem, either use n_channels=3 when creating the renderer or use a 4D feature vector. :) ...
Read more >
Runtime Error: What It Is and How to Fix It - Lifewire
Runtime errors prevent a program from working properly. Here's how to fix runtime errors caused my memory issues, unpatched bugs, and more.
Read more >
Facing Run-time error '619' while running T code solar02 ...
Hi , To view TD's in SOLMAN using T code solar02, we are automating the procedure with VBA script. We are facing a...
Read more >
Runtime Errors - GeeksforGeeks
A runtime error in a program is an error that occurs while the program is running after being successfully compiled.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found