Comments (3)
I am curious about this, please tell us when you tried this. I have found that CoorConvs
help to get better results consistently, they act as positional embeddings.
class AddCoords(Module):
"Add coordinates to image"
def __init__(self, with_r=False):
self.with_r = with_r
def forward(self, input_tensor):
"""
Args:
input_tensor: shape(batch, channel, x_dim, y_dim)
"""
batch_size, _, x_dim, y_dim = input_tensor.size()
xx_channel = torch.arange(x_dim).repeat(1, y_dim, 1)
yy_channel = torch.arange(y_dim).repeat(1, x_dim, 1).transpose(1, 2)
xx_channel = xx_channel.float() / (x_dim - 1)
yy_channel = yy_channel.float() / (y_dim - 1)
xx_channel = xx_channel * 2 - 1
yy_channel = yy_channel * 2 - 1
xx_channel = xx_channel.repeat(batch_size, 1, 1, 1).transpose(2, 3)
yy_channel = yy_channel.repeat(batch_size, 1, 1, 1).transpose(2, 3)
ret = torch.cat([
input_tensor,
xx_channel.type_as(input_tensor),
yy_channel.type_as(input_tensor)], dim=1)
if self.with_r:
rr = torch.sqrt(torch.pow(xx_channel.type_as(input_tensor) - 0.5, 2) + torch.pow(yy_channel.type_as(input_tensor) - 0.5, 2))
ret = torch.cat([ret, rr], dim=1)
return ret
and the conv:
@delegates(nn.Conv2d)
class CoordConv(Module):
"Like a 2D Conv but with coordinates"
def __init__(self, in_channels, out_channels, kernel_size, **kwargs, ):
self.addcoords = AddCoords(with_r=True)
in_size = in_channels+3
self.conv = nn.Conv2d(in_size, out_channels, kernel_size, **kwargs)
def forward(self, x):
ret = self.addcoords(x)
ret = self.conv(ret)
return ret
from satflow.
Oh interesting! Yeah, I'll update this issue when I try it out to see if it makes a difference. Still have been working out a few kinks in the data pipeline, but it seems good to go now. I'll also try benchmarking models with your approach as well, to see how it works with all three.
from satflow.
This library also seems like a cool way to easily try out BlurPool, and other things with Torch models: https://github.com/mosaicml/composer
from satflow.
Related Issues (20)
- Simulated Optical Flow using real clouds HOT 6
- Split out Skillful Nowcasting GAN, MetNet, and PerceiverIO models into own repos HOT 6
- Create output video visualizations HOT 4
- Split out base utils along with predict_pv_yield's HOT 2
- Format docstrings so they pass `pydocstyle`'s criteria HOT 2
- Update Perceiver and MetNet to use NWP data + other Nowcasting Dataset data HOT 1
- Pretrain on data from Weather4cast HOT 4
- Add Joint Model HOT 2
- Add CI/CD Model Runs HOT 2
- New paper: SPATE-GAN: Improved Generative Modeling of Dynamic Spatio-Temporal Patterns with an Autoregressive Embedding Loss HOT 1
- clarify development status HOT 2
- New paper: PolyViT HOT 2
- error: package directory 'satflow/data' does not exist HOT 2
- New Paper: RETRO HOT 1
- New Paper: Transformer Uncertainty Estimation with Hierarchical Stochastic Attention HOT 2
- New Paper: Data2Vec
- VICReg: Variance-Invariance-Covariance Regularization for Self-Supervised Learning
- Similar Datasets HOT 1
- document loss
- document loss
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from satflow.