weixin_39907526
2020-12-06 18:20 阅读 0

NumpyBackend.dtype returns wrong type

The return type of NumpyBackend.dtype is currently given by the type of the dtype argument at initialization, but it should always yield a numpy.dtype object:

python 
be = NumpyBackend(dtype=np.float64)
be.dtype #this is a `type` object, i.e. a `np.float64`

The fix is

python 
class NumPyBackend(base_backend.BaseBackend):
  """See base_backend.BaseBackend for documentation."""

  def __init__(self, dtype: Optional[numpy.dtype] = None):
    super(NumPyBackend, self).__init__()
    self.np = numpy
    self.name = "numpy"
    self._dtype =dtype# -> self._dtype = numpy.dtype(dtype)

该提问来源于开源项目:google/TensorNetwork

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39972996 weixin_39972996 2020-12-06 18:20

    , you're quite busy with other things, so I'd be happy to fix this and add tests if you're not on it yet.

    点赞 评论 复制链接分享
  • weixin_39907526 weixin_39907526 2020-12-06 18:20

    That would be great, thanks!

    点赞 评论 复制链接分享
  • weixin_39907526 weixin_39907526 2020-12-06 18:20

    btw, the jax backend needs also to be fixed

    点赞 评论 复制链接分享
  • weixin_39972996 weixin_39972996 2020-12-06 18:20

    on it!

    点赞 评论 复制链接分享

相关推荐