batch_size的探索 女爷i 2024-04-01 12:43 10阅读 0赞 ## **问题** ## test\_loader 中的y 表示每一个batch对应的128张图片对应的数字,torch.Size(\[256\])表示什么意思? ![18957d44844f499fb5ec91a5a5f6293d.png][] ![389be20f8dd396989af922ec74955483.png][] ## ## ## **方法** ## <table> <tbody> <tr> <td>在打印了X的长度之后,发现X的长度也为256,这表示此处用作测试的X是由256个1x28x28的矩阵构成的多元组矩阵集合。也即,y的长度为256,而不是128。<br><img alt="71e84635e3c23b32bfb7f30166cecc81.png" src="https://img-blog.csdnimg.cn/img_convert/71e84635e3c23b32bfb7f30166cecc81.png"><br> for X, y in test_loader: <br> print(X.shape, y.shape)<br> print(y)<br> print(len(X))<br> print(X)<br> 原因:<br> 在初次设置test_loader的batch_size为256,而不是128.<br><img alt="aa97253f5450b86d4eb3fe1e5ab431c5.png" src="https://img-blog.csdnimg.cn/img_convert/aa97253f5450b86d4eb3fe1e5ab431c5.png"></td> </tr> </tbody> </table> ## ## ## **结语** ## 在本次探索中,通过print(),我对test\_loader中的(X, y)的数据格式有了一定的认识,同时对batch\_size的重要性有了一定的了解。 [18957d44844f499fb5ec91a5a5f6293d.png]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/01/9a8b1b11086c420cb379a7bebb5e43e8.png [389be20f8dd396989af922ec74955483.png]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/01/9d1da2889a6c472185fa846474153013.png
还没有评论,来说两句吧...