model.py中nn是哪个package里面来的?
bixingjian opened this issue · 1 comments
bixingjian commented
在 model.py
中:
from transformers.models.bert.modeling_bert import *
from torch.nn.utils.rnn import pad_sequence
from torchcrf import CRF
class BertNER(BertPreTrainedModel):
def __init__(self, config):
super(BertNER, self).__init__(config)
self.num_labels = config.num_labels
self.bert = BertModel(config)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
self.bilstm = nn.LSTM(
input_size=config.lstm_embedding_size, # 1024
hidden_size=config.hidden_size // 2, # 1024
batch_first=True,
num_layers=2,
dropout=config.lstm_dropout_prob, # 0.5
bidirectional=True
)
self.classifier = nn.Linear(config.hidden_size, config.num_labels)
self.crf = CRF(config.num_labels, batch_first=True)
self.init_weights()
比如这里self.dropout = nn.Dropout(config.hidden_dropout_prob)
, 并没有导入import torch.nn as nn
这里的nn是哪个package里面来的?
hemingkx commented
from transformers.models.bert.modeling_bert import *,从这里来的~