Comments (7)
Hi, this only changes the array order, the content is the same I believe. The list is shuffled anyway as part of the training in split_train_val
(utils/utils.py). In this case I loop over the i inside the loop over ids, so the result is something like
[(id1, 0), (id1, 1), (id2, 0), (id2, 1), ...]
.
Edit: I'm wrong, the order of the for loops is left to right
from pytorch-unet.
@milesial I find this problem as well, we hope the return of this function (split_ids) is like the form :
[(id1, 0), (id1, 1), (id2, 0), (id2, 1), ...]. The code "((id, i) for id in ids for i in range(n))" can get this output. And your version "((id, i) for i in range(n) for id in ids)" is supposed to output like this:
[(id1, 0), (id2, 0),... ,(id1, 1), (id2, 1) ...], however it just output [(id1, 0), (id2, 0),...] , without (id1, 1), (id2, 1) ...
from pytorch-unet.
That's strange ! When n=2, on python3, all went fine for me. If the order is wrong that does not matter because it's shuffled but if half the values are missing that's a problem...
If I run this code [(id, i) for i in range(2) for id in ['id1', 'id2', 'id3']]
I get [('id1', 0), ('id2', 0), ('id3', 0), ('id1', 1), ('id2', 1), ('id3', 1)]
, which is fine. Is it the same on your setup ?
from pytorch-unet.
@milesial I think I find the reason of this strange result. The code "((id, i) for i in range(n) for id in ids)" can expand as this :
for i in range(n):
for id in ids:
.....
In the first loop of ids(when n = 0), the iter ids has been iterated out, so in the next loop(when n = 1), there's no element in iter ids. And this result the output with only half the value [(id1, 0), (id2, 0),...] .
However, the code "((id, i) for id in ids for i in range(n))" just iterate the ids once, so it works well.
Of course, above is my own opinion, maybe not correct.
from pytorch-unet.
Ooh you're right ! Nice catch, indeed ids is a generator so it runs out. This can be fixed by either returning a list in the function get_ids
, or copying the ids
generator before iterating over it.
from pytorch-unet.
Thanks for your reply! I agree with your solution for this. Maybe the developers of Python can alter the mechanism of the iterator so that it won't iterate in "for...in..." code, only if we run 'next()' or "next"
^_^
from pytorch-unet.
Haha it would break many projects, even my train loop relies on the fact that the train iterator finishes.
from pytorch-unet.
Related Issues (20)
- Refer the datasets to download from Kaggle
- Windows .bat setup script HOT 1
- Latest Python versions have deprecated `distutils` module
- How to accurately calculate Model Parameters and GFLOPs?
- thanks a lot, your model help me lot, I make a grad-cam to mark what place the U-Net look, also named hot-map HOT 1
- The training loss is always nan. HOT 3
- dice = ? 0.5
- miou and acc
- 为什么预测出来的图片全黑,能不能回复一下 HOT 3
- can't change batch_size
- IndexError: list index out of range
- Python version HOT 1
- My own dataset reported an error
- Did you use "crop" in the skip connection? or you just connect them? HOT 1
- train error
- wandb issue HOT 4
- Trained Check Points not Working HOT 1
- about export pth to onnx
- what does n_classes=1 mean?
- A confusion in hubconf.py
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 pytorch-unet.