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

warmup learning rate should be float? #127

Closed
3zhang opened this issue Jun 3, 2024 · 4 comments
Closed

warmup learning rate should be float? #127

3zhang opened this issue Jun 3, 2024 · 4 comments

Comments

@3zhang
Copy link

3zhang commented Jun 3, 2024

Current:

    parser.add_argument("--warmup-learning-rate", type=int, default=1e-6,
                        help="learning rate for warmup")
@3zhang 3zhang changed the title warm learning rate should be float? warmup learning rate should be float? Jun 3, 2024
@nagadomi
Copy link
Owner

nagadomi commented Jun 4, 2024

You're right.
Also warmup option has a problem that only applies the first 1 epoch.

I can't touch my pc now. I will check when I get home .(next week)

@3zhang
Copy link
Author

3zhang commented Jun 12, 2024

You're right. Also warmup option has a problem that only applies the first 1 epoch.

I can't touch my pc now. I will check when I get home .(next week)

I read your code of Waifu2xDataset. For the __getitem__, at the end there's a line TF.pad(y, [-self.model_offset] * 4). Could you explain a little bit? What is model_offset?

@nagadomi
Copy link
Owner

What is model_offset?

model_offset is the unpad size of the model output.

Historically, waifu2x models do not use zero padding for conv2d. This is because of the problem of visible seams in tiled rendering. ( releated to nagadomi/waifu2x#238 , The quoted comment was written by me. )

So the output size of the model will be smaller than 2x the input.
For example, UpConv7.i2i_scale = 2, UpConv7.i2i_offset = 14

class UpConv7(I2IBaseModel):
name = "waifu2x.upconv_7"
def __init__(self, in_channels=3, out_channels=3):
super(UpConv7, self).__init__(locals(), scale=2, offset=14, in_channels=in_channels)

input x = 256x256

if __name__ == "__main__":
import torch
from nunif.models import create_model
device = "cuda:0"
model = create_model(UpConv7.name, in_channels=3, out_channels=3).to(device)
print(model)
x = torch.zeros((1, 3, 256, 256)).to(device)
with torch.no_grad():
z = model(x)
print(z.shape)
print(model.name, model.i2i_offset, model.i2i_scale)

torch.Size([1, 3, 484, 484])

output size is 484x484.

output_size = input_size * scale - offset * 2 ( 484 = 256 * 2 - 14 * 2)

@nagadomi
Copy link
Owner

Fixed 5b30b03

Also warmup option has a problem that only applies the first 1 epoch.

This problem has not yet fixed.

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

2 participants