# Testing with a subset of Train Data?

**URL:** <https://discuss.pytorch.org/t/testing-with-a-subset-of-train-data/43755>\
**Category:** Uncategorized\
**Created:** [April 27, 2019, 9:07am UTC](https://discuss.pytorch.org/t/testing-with-a-subset-of-train-data/43755 "2019-04-27T09:07:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karsten](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/karsten/32/11513_2.png) [@Karsten](https://discuss.pytorch.org/u/Karsten)\
**Post date:** [April 27, 2019, 9:07am UTC](https://discuss.pytorch.org/t/testing-with-a-subset-of-train-data/43755/1 "2019-04-27T09:07:25Z")

</div>

Hello,  
I’m new to neural networks and have an issue with Data splitting. Currently my code looks like this:

```auto
train, test = D[:round(len(D)*0.8)], D[round(len(D)*0.2):]

```

Am I testing with a subset of training Data? And if so, how could I fix this?  
Thanks for your answer 🙂

---

<div class="post-metadata">

**Author:** ![Oli](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/oli/32/9773_2.png) [@Oli](https://discuss.pytorch.org/u/Oli)\
**Post date:** [April 27, 2019, 10:10am UTC](https://discuss.pytorch.org/t/testing-with-a-subset-of-train-data/43755/2 "2019-04-27T10:10:59Z")

</div>

Hello! that code takes the first 80% of the data and puts that into train. Then it skips the first 20% and puts the rest into test. Not how we want it. I’d change the code to something like this

```auto
split = round(len(D)*0.8) # The index which marks 80% of the data
train = D[:split] # Takes the first 80% of data
test = D[split:] # Takes whatever is left after the first 80% of data -> last 20% of data

```

---

<div class="post-metadata">

**Author:** ![Karsten](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/karsten/32/11513_2.png) [@Karsten](https://discuss.pytorch.org/u/Karsten)\
**Post date:** [April 27, 2019, 11:22am UTC](https://discuss.pytorch.org/t/testing-with-a-subset-of-train-data/43755/3 "2019-04-27T11:22:42Z")

</div>

Thank you very much 🙂  
It worked…
