【问题标题】:PyTorch is crashing the jupyter notebook, while calculating the loss using nn module?PyTorch 正在使 jupyter 笔记本崩溃,同时使用 nn 模块计算损失?
【发布时间】:2018-12-23 07:12:11
【问题描述】:
model = nn.Sequential(nn.Linear(784, 128),
                  nn.ReLU(),
                  nn.Linear(128, 64),
                  nn.ReLU(),
                  nn.Linear(64, 10))

criterion = nn.CrossEntropyLoss()

images, labels = next(iter(trainloader))
images = images.view(images.shape[0], -1) 
logits = model(images)
loss = criterion(logits, labels) 
print(loss)

代码在“loss = criteria(logits, labels)”行崩溃。
数据集:MNIST 手写数字。

【问题讨论】:

    标签: jupyter-notebook pytorch


    【解决方案1】:

    就我而言, 我通过将 pytorch 版本从 v1.0 降级并安装到 0.4.0 解决了这个问题。
    如何安装 v0.4.0 ?
    只需将版本名称从 1.0.0 更改为 0.4.0

    1. pip3 安装https://download.pytorch.org/whl/cpu/torch-1.0.0-cp36-cp36m-linux_x86_64.whl
    2. pip3 安装 torchvision

    1. pip3 安装https://download.pytorch.org/whl/cpu/torch-0.4.0-cp36-cp36m-linux_x86_64.whl
    2. pip3 安装 torchvision

    这适用于 Ubuntu 18.04 操作系统,使用 pip,非 CUDA 安装。

    【讨论】:

    • 在他们的 Github 存储库中报告听起来是个不错的问题 - 因为它在 v0.4 中工作,它绝对不会在 v1.0 中使您的程序崩溃
    猜你喜欢
    • 1970-01-01
    • 2019-04-23
    • 2018-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 2021-04-24
    • 1970-01-01
    相关资源
    最近更新 更多