train.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:char-rnn 作者: hiepph 项目源码 文件源码
def __init__(self, input_size, hidden_size, output_size, n_layers=1, gpu=-1):
        self.decoder = RNN(input_size, hidden_size, output_size, n_layers, gpu)
        if gpu >= 0:
            print("Use GPU %d" % torch.cuda.current_device())
            self.decoder.cuda()

        self.optimizer = torch.optim.Adam(self.decoder.parameters(), lr=0.01)
        self.criterion = nn.CrossEntropyLoss()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号