测试中比较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
```




欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在IE10中重新加载另一个帧时,internet explorer Java小程序失败/消失   ThreadLocal变量的java性能   java系统。出来println不是打印输出   java从JAXB类获取元素属性   java组织。天啊。科尔巴。包裹。InvalidName:IDL:omg。org/CORBA/ORB/InvalidName:1.0   java有没有办法让非事务连接抛出异常?   java是否有任何方法可以使用JdbcTemplate和查询/条件Fluent API   javajpa级联类型。刷新不工作?   未考虑java Maven依赖关系管理   java MySQL MBR包含抛出MySQLExceptionError的语句   java验证整数并将其设为5位数   java发现了循环依赖的问题   java Hibernate left join fetch到使用@ManyToMany关联映射的softdeleted实体生成无效查询?   JavaH:commandButton多个操作:下载文件并呈现ajax表   Google Contacts API在Java、C#、Python或Ruby中是否有一个Hello World示例?