Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyTorch中输出大小可变的多对多RNN_Python_Machine Learning_Deep Learning_Pytorch_Recurrent Neural Network - Fatal编程技术网

Python PyTorch中输出大小可变的多对多RNN

Python PyTorch中输出大小可变的多对多RNN,python,machine-learning,deep-learning,pytorch,recurrent-neural-network,Python,Machine Learning,Deep Learning,Pytorch,Recurrent Neural Network,我正在尝试实现多对多RNN网络。我已将模型和前进道具定义如下: class ManyToManyRNN(nn.Module): def __init__(self, hid_size=100, output_dim): super(ManyToManyRNN, self).__init__() self.hidden_size = hid_size self.output_dim = output_dim self.rnn

我正在尝试实现多对多RNN网络。我已将模型和前进道具定义如下:

class ManyToManyRNN(nn.Module):
    def __init__(self, hid_size=100, output_dim):
        super(ManyToManyRNN, self).__init__()
        self.hidden_size = hid_size
        self.output_dim = output_dim
        self.rnn = nn.LSTM(input_size=4, hidden_size=self.hidden_size, num_layers=1, batch_first=True)
        self.fc1 = nn.Linear(self.hidden_size, self.output_dim)

    def forward(self, inputs):
        outputs = []
        rnn_out, _ = self.rnn(inputs)
        output = self.fc1(rnn_out[:, -1])
        return output
我可以在初始化类时设置
output\u dim
的值,然后将该值固定。但是,在我的应用程序中,输出维度的值不断变化。我无法事先确定
output\u dim
的值

我的问题是,如何构造一个输出维度灵活的多对多RNN?我愿意更改模型的体系结构以实现此功能。感谢您的帮助