由于观察不能揭示整个状态,我需要使用递归神经网络进行强化,以便网络对过去发生的事情有某种记忆。为简单起见,我们假设使用LSTM。
现在,内置的shape LSTM需要向它提供shape Time x MiniBatch x Input D的一个PyTorch输入,它输出shape Time x MiniBatch x Output D的张量。
然而,在强化学习中,要知道time t+1的输入,我需要知道time t的输出,因为我是在环境中执行操作。
那么,有没有可能使用内置的BPTT在强化学习环境中进行PyTorch?如果是的话,我该怎么做呢?
我正在尝试根据测试集dataloader从我的模型中获得预测(希望同时保存x和y^hat,稍后我需要对它们进行测试)。
我试过:
my_results = trainer.predict(model = model, datamodule=dm)
使用我的代码中的下列项:
class TimeseriesDataset(Dataset):
'''
Custom Dataset subclass.
Serves as input to DataLoader to transform X
into sequence data u
我正在尝试使用pytorch训练一个DNN模型,并且我想使用GPU来训练我的模型。我可以使用model.to(device)成功地将我的模型复制到图形处理器,其中device = cuda:0。 但是,将输入复制到图形处理器的标准方法(RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same),即X.to(device)和X.cuda()并不能提供所需的输出。以下是我目前正在实现的方法: def train_loop(self, datalo
我正在尝试在colab中复制pytorch的N- Beats模型。我将相同的代码从复制到colab笔记本。在训练单元中出现错误。
import os
import warnings
warnings.filterwarnings("ignore")
os.chdir("../../..")
import pandas as pd
import pytorch_lightning as pl
from pytorch_lightning.callbacks import EarlyStopping
import torch
from pytorch_fore
我正在尝试弄清楚如何使用LSTM/GRU构建一个模型,该模型可以预测多对多,但对于每n次(在我的例子中是7次)输入。例如,我的输入数据有一整年每天的时间步长,但我只尝试预测每周结束时的输出,而不是每天。 我能找到的唯一信息是这个答案:Many to one and many to many LSTM examples in Keras 它说:“当步数不同于输入/输出长度时,多对多:这在Keras中是异常困难的。没有容易的代码片段来编码。” 在pytorch中,似乎你可以在损失函数中设置ignore_index,我认为这应该可以做到这一点。 keras有解决方案吗?
我用PyTorch实现了一个LSTM,如下所示。 import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class LSTM(nn.Module):
"""
Defines an LSTM.
"""
def __init__(self, input_dim, hidden_dim, output_dim, num_lay
所以,我正在运行这个深度神经网络。通常,当我使用没有cuda的pytorch库与cpu一起训练它时,它运行得很好。
但是,我注意到当我安装pytorch+cuda 11.1时,每当我试图在Dataloader上枚举时,就会抛出以下错误:
OSError: [WinError 1455] The paging file is too small for this operation to complete. Error loading "C:\Users\Name\Desktop\Folder\lib\site-packages\torch\lib\cudnn_adv_train64_8
我正在使用PyTorch闪电和PyTorch进行LSTM分类。每当我训练模型时,这个错误显示:
File "<string>", line 1, in <module>
File "C:\Users\hisha\anaconda3\envs\FYP\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\hisha\anaconda3\envs\FYP\li