Comments (2)
感谢提问。
在Line25中对exchange_mask进行了batch维度的扩充。
exchange_map = torch.arange(c) % self.p == 0
exchange_mask = exchange_map.unsqueeze(0).expand((N, -1))
因此,在交换时直接省略了batch维。您可以用以下代码进行验证:
import torch
x1 = torch.arange(1, 128+1).reshape(4, 8, 2, 2)
x2 = torch.arange(1, 128+1).reshape(4, 8, 2, 2) * -1
p = 2
N, c, h, w = x1.shape
exchange_map = torch.arange(c) % p == 0
exchange_mask = exchange_map.unsqueeze(0).expand((N, -1))
out_x1, out_x2 = torch.zeros_like(x1), torch.zeros_like(x2)
out_x1[~exchange_mask, ...] = x1[~exchange_mask, ...]
out_x2[~exchange_mask, ...] = x2[~exchange_mask, ...]
out_x1[exchange_mask, ...] = x2[exchange_mask, ...]
out_x2[exchange_mask, ...] = x1[exchange_mask, ...]
exchange_mask = exchange_map
out_x11, out_x22 = torch.zeros_like(x1), torch.zeros_like(x2)
out_x11[:, ~exchange_mask, ...] = x1[:, ~exchange_mask, ...]
out_x22[:, ~exchange_mask, ...] = x2[:, ~exchange_mask, ...]
out_x11[:, exchange_mask, ...] = x2[:, exchange_mask, ...]
out_x22[:, exchange_mask, ...] = x1[:, exchange_mask, ...]
print(torch.all(out_x1 == out_x11), torch.all(out_x2 == out_x22))
from open-cd.
谢谢,学习了一波
from open-cd.
Related Issues (20)
- Welcome update to OpenMMLab 2.0 HOT 2
- Roadmap of Open-CD HOT 1
- IndexError: index 10995116278530 is out of bounds for dimension 0 with size 1024 HOT 9
- tool/publish_model.py output file name error HOT 1
- evaluation metrics for s2looking HOT 1
- Dataset configuration files 'multiple values for keyword argument' HOT 2
- exhanger window HOT 1
- Problems in training stage HOT 1
- 'LEVIR_CD_Dataset' is not in the dataset registry HOT 2
- 作者您好,我在运行最新版本代码的训练命令时,代码出现如下报错,想请问作者解决方法?十分感谢 HOT 4
- No module named 'mmcv' HOT 2
- 请问怎么利用cutmix和mixup HOT 2
- CDD dataset and resuming training HOT 4
- ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' HOT 6
- Bug in TinyCD_V2 and GPU usage question HOT 3
- How to obtain the mmsegmentation-pretrained backbone checkpoint? HOT 2
- 在windows下是否可以训练 HOT 1
- Can't reproduce the results of configs/changer/changer_ex_mit-b0_512x512_40k_levircd.py 84.37VS85.29 HOT 4
- assert pred.size() == target.size() and target.numel() > 0 HOT 1
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 open-cd.