Coder Social home page Coder Social logo

Comments (8)

lucidrains avatar lucidrains commented on August 22, 2024 1

There's a bug in my code and SLE spatial is always on 🙈🙈

from lightweight-gan.

lucidrains avatar lucidrains commented on August 22, 2024 1

SLE spatial is basically squeeze excitation, but done in the spatial dimension rather than the channel dimension

from lightweight-gan.

woctezuma avatar woctezuma commented on August 22, 2024

Oops.

SLE

from lightweight-gan.

woctezuma avatar woctezuma commented on August 22, 2024

I realize that this explains what SLE means, but not whether I should activate Spatial SLE.

class SLE(nn.Module):
def __init__(
self,
*,
chan_in,
chan_out
):
super().__init__()
self.avg_pool = nn.AdaptiveAvgPool2d((4, 4))
self.max_pool = nn.AdaptiveMaxPool2d((4, 4))
chan_intermediate = chan_in // 2
self.net = nn.Sequential(
nn.Conv2d(chan_in * 2, chan_intermediate, 4),
nn.LeakyReLU(0.1),
nn.Conv2d(chan_intermediate, chan_out, 1),
nn.Sigmoid()
)
def forward(self, x):
pooled_avg = self.avg_pool(x)
pooled_max = self.max_pool(x)
return self.net(torch.cat((pooled_max, pooled_avg), dim = 1))

class SpatialSLE(nn.Module):
def __init__(self, upsample_times, num_groups = 2):
super().__init__()
self.num_groups = num_groups
chan = num_groups * 2
self.net = nn.Sequential(
nn.Conv2d(chan, chan, 3, padding = 1),
upsample(2 ** upsample_times),
nn.Conv2d(chan, chan, 3, padding = 1),
nn.LeakyReLU(0.1),
nn.Conv2d(chan, 1, 3, padding = 1),
nn.Sigmoid()
)
def forward(self, x):
b, c, h, w = x.shape
num_groups = self.num_groups
mult = math.ceil(c / num_groups)
padding = (mult - c % mult) // 2
x_padded = F.pad(x, (0, 0, 0, 0, padding, padding))
x = rearrange(x_padded, 'b (g c) h w -> b g c h w', g = num_groups)
pooled_avg = x.mean(dim = 2)
pooled_max, _ = x.max(dim = 2)
pooled = torch.cat((pooled_avg, pooled_max), dim = 1)
return self.net(pooled)

from lightweight-gan.

bogdan-ivan avatar bogdan-ivan commented on August 22, 2024

I have seen in your thread "Optimal parameters for Google Colab" that you ended up dropping sle_spatial, have you noticed a difference in the results ?

from lightweight-gan.

woctezuma avatar woctezuma commented on August 22, 2024

I have seen in your thread "Optimal parameters for Google Colab" that you ended up dropping sle_spatial, have you noticed a difference in the results ?

No, I cannot talk about that. I dropped this parameter for now only because:

  • I was not sure about its effect,
  • I wanted to have a the simplest command-line possible, to make sure that the long run-times were not due to my choice of command-line options.

from lightweight-gan.

lucidrains avatar lucidrains commented on August 22, 2024

ok, sle-spatial should be fixed in the latest version

from lightweight-gan.

Dok11 avatar Dok11 commented on August 22, 2024

There's a bug in my code and SLE spatial is always on 🙈🙈

@lucidrains why SLE spatial disabled by default?

from lightweight-gan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.