测试中比较pytorch张量的断言方法集合
torch-testing的Python项目详细描述
#torch testing
一组断言方法,用于比较测试中的pytorch张量。
目前,所有断言方法都是通过将张量转换为numpy数组并将其馈送到适当的“numpy.testing”方法来提供的。这样,在失败时,将提供有关测试失败原因的详细信息。
最后一次使用**python 3.6.4::anaconda进行测试,公司*和**Pythorch 0.4**.
/>进口火炬测试
>class-testsomeclass(unittestest.testcase):
>def-test一些方法(self):
>a=torch.张量([1,2])
>b=torch.张量([1,2])
35assertion方法**kwargs)`
目前,这种断言方法是通过使用“tensor.numpy()”将张量转换为“numpy”数组,并将其馈送给[numpy.testing.assert戋equal](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert戋equal.html戋numpy.testing.assert戋equal)来提供的(实际的,预期的,rtol=1e-07,atol=0,等于n=true,**kwargs)`
目前,这种断言方法是通过使用“tensor.numpy()”将张量转换为“numpy”数组,并将其馈送给[numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html numpy.testing.assert_allclose)来提供的。max_val,rtol=0)`
确保给定“张量”的所有值都大于或等于“min_val”且小于或等于“max_val”。允许指定相对公差“rtol”,其行为类似于[numpy.testing.assert_llclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_llclose.html numpy.testing.assert_llclose)。
*注意:在引擎盖下使用“assert_llclose”,因此失败消息当前可能有点混乱。*
##development
*除非另有说明,否则所有命令都将从该存储库的根目录执行。*
\运行pip install-e.
```
```sh
pip install-e.
```
``sh
python-m unittest discover tests
```
一组断言方法,用于比较测试中的pytorch张量。
目前,所有断言方法都是通过将张量转换为numpy数组并将其馈送到适当的“numpy.testing”方法来提供的。这样,在失败时,将提供有关测试失败原因的详细信息。
最后一次使用**python 3.6.4::anaconda进行测试,公司*和**Pythorch 0.4**.
/>进口火炬测试
>class-testsomeclass(unittestest.testcase):
>def-test一些方法(self):
>a=torch.张量([1,2])
>b=torch.张量([1,2])
35assertion方法**kwargs)`
目前,这种断言方法是通过使用“tensor.numpy()”将张量转换为“numpy”数组,并将其馈送给[numpy.testing.assert戋equal](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert戋equal.html戋numpy.testing.assert戋equal)来提供的(实际的,预期的,rtol=1e-07,atol=0,等于n=true,**kwargs)`
目前,这种断言方法是通过使用“tensor.numpy()”将张量转换为“numpy”数组,并将其馈送给[numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html numpy.testing.assert_allclose)来提供的。max_val,rtol=0)`
确保给定“张量”的所有值都大于或等于“min_val”且小于或等于“max_val”。允许指定相对公差“rtol”,其行为类似于[numpy.testing.assert_llclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_llclose.html numpy.testing.assert_llclose)。
*注意:在引擎盖下使用“assert_llclose”,因此失败消息当前可能有点混乱。*
##development
*除非另有说明,否则所有命令都将从该存储库的根目录执行。*
\运行pip install-e.
```
```sh
pip install-e.
```
``sh
python-m unittest discover tests
```