小编Hil*_*urn的帖子

将CSV解析为Pytorch张量

我有一个CSV文件,其中包含标题行以外的所有数字值。尝试构建张量时,出现以下异常:

Traceback (most recent call last):
  File "pytorch.py", line 14, in <module>
    test_tensor = torch.tensor(test)
ValueError: could not determine the shape of object type 'DataFrame'
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import torch
import dask.dataframe as dd

device = torch.device("cuda:0")

print("Loading CSV...")
test = dd.read_csv("test.csv", encoding = "UTF-8")
train = dd.read_csv("train.csv", encoding = "UTF-8")

print("Converting to Tensor...")
test_tensor = torch.tensor(test)
train_tensor = torch.tensor(train)
Run Code Online (Sandbox Code Playgroud)

使用pandas而不是DaskCSV解析会产生相同的错误。我也尝试dtype=torch.float64在对的调用中指定torch.tensor(data),但再次遇到相同的错误。

python pandas pytorch

2
推荐指数
3
解决办法
5908
查看次数

Latex 首字母缩略词包“未找到 acronym.sty”

尝试使用该acronym软件包时遇到错误。我所有需要的包都在一个myPreamble.sty文件中,我将它加载到我的主tex文件中\usepackage{myPreamble}
我添加\usepackage{acronym}到所述文件中,但是在运行时pdflatex main.tex我收到了
! LaTeX Error: File 'acronym.sty' not found. 我阅读的消息acronymrequires suffix,所以我也添加了它myPreamble,但这导致了
! LaTeX Error: File 'suffix.sty' not found.
如何生成这些文件?

latex

1
推荐指数
1
解决办法
7967
查看次数

标签 统计

latex ×1

pandas ×1

python ×1

pytorch ×1