You advice helps a lot. I tested the example in my program and the example ran normally.Then I changed the input into the ‘outputs’ above. The error ‘expected float but long given’ appeared. I removed the ‘outputs = outputs.long()’ and the program ran normally.
This is the code after modifying.
import sys
import os
sys.path.append(os.getcwd())
import torch
import torch.nn as nn
from config import Config


class FC(nn.Module):
    def __init__(self, opt):
        super(FC, self).__init__()
        self.encoder = nn.Embedding(opt.VOCAB_SIZE, opt.EMBEDDING_DIM)
        self.rnn = nn.GRU(100,128,2)
        self.relu = nn.ReLU(False)
        self.fc_1 = nn.Sequential(
            nn.Linear(12800, opt.LINER_HID_SIZE),
            #nn.BatchNorm1d(opt.LINER_HID_SIZE),
            nn.ReLU(False),
            nn.Linear(opt.LINER_HID_SIZE, opt.NUM_CLASS_1*10),
            nn.ReLU(False),
            nn.Linear(opt.NUM_CLASS_1*10, opt.NUM_CLASS_1),
            nn.Dropout(0.5),
        )
        self.fc_2 = nn.Sequential(
            nn.Linear(12800, opt.LINER_HID_SIZE),
            #nn.BatchNorm1d(opt.LINER_HID_SIZE),
            nn.ReLU(False),
            nn.Linear(opt.LINER_HID_SIZE, opt.NUM_CLASS_2*10),
            nn.ReLU(False),
            nn.Linear(opt.NUM_CLASS_2*10, opt.NUM_CLASS_2),
            nn.Dropout(0.5),
        )
        self.fc_3 = nn.Sequential(
            nn.Linear(12800, opt.LINER_HID_SIZE),
            #nn.BatchNorm1d(opt.LINER_HID_SIZE),
            nn.ReLU(False),
            nn.Linear(opt.LINER_HID_SIZE, opt.NUM_CLASS_3*10),
            nn.ReLU(False),
            nn.Linear(opt.NUM_CLASS_3*10, opt.NUM_CLASS_3),
            nn.Dropout(0.5),
        )

    def forward(self, x):
        x = x.long()
        outputs = self.encoder(x)
        h0 = torch.randn(2,100,128).cuda()
        outputs,ht = self.rnn(outputs, h0)
        outputs = self.relu(outputs)
        outputs = outputs.view(outputs.size()[0], -1)
        output_1 = self.fc_1(outputs)
        output_2 = self.fc_2(outputs)
        output_3 = self.fc_3(outputs)
        return (output_1, output_2, output_3)



Thanks very much again!