admin管理员组文章数量:1794759
creating a tensor from a list of numpy.ndarray is extremely slow Please consider converting the lis
我的代码如下
node_2_neg_list = [torch.Longtensor(node) for node in node_2_negative]其中node_2_negative是一个list,里面有16个元素: 每个元素又是一个list,里面与10个元素: 而每个元素中又包含10个元素: 所以这是一个list嵌套list的情况,而我们执行上面的代码,提示信:
creating a tensor from a list of numpy.ndarray is extremely slow Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor.因此根据其实信,我们需要将list先转成numpy.ndarray然后再转成tensor,原先的node_2_negative[0]数据如下:
然后转成ndarray类型: 这样就可以放心的把数据转为tensor了:
node_2_neg_list = [torch.LongTensor(np.array(node)) for node in node_2_negative]本文标签: listnumpycreatingtensorndarray
版权声明:本文标题:creating a tensor from a list of numpy.ndarray is extremely slow Please consider converting the lis 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686552083a80998.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论