【问题标题】:How to solve "No module named 'tools'" in google colab?如何解决google colab中“没有名为'tools'的模块”?
【发布时间】:2019-12-27 23:18:39
【问题描述】:

我正在尝试按照本教程在我的数据中应用 Bert:https://medium.com/swlh/a-simple-guide-on-using-bert-for-text-classification-bbf041ac8d04

在导入时出现错误

这是我要导入的内容

import torch
import pickle
from torch.utils.data import (DataLoader, RandomSampler, SequentialSampler, TensorDataset)
from torch.nn import CrossEntropyLoss, MSELoss

from tqdm import tqdm_notebook, trange
import os
from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM, BertForSequenceClassification
from pytorch_pretrained_bert.optimization import BertAdam, WarmupLinearSchedule

from multiprocessing import Pool, cpu_count
from tools import *
import convert_examples_to_features

并且出现错误:from tools import * as "No module named 'tools'"。

我尝试遵循一些答案,例如: Python/Caffe2: ImportError: No module named tools.setup_helpers.env

pyserial: No module named tools

ModuleNotFoundError: No module named 'tools.nnwrap'

但是,这些答案并没有解决我的错误。

请帮忙!

【问题讨论】:

标签: python pytorch google-colaboratory


【解决方案1】:

该错误可能是因为您的工作文件夹中没有 tools.py 文件。您可以从您所指的教程中提到的 GitHub 位置获取该文件。这是供您参考的链接。 https://github.com/ThilinaRajapakse/BERT_binary_text_classification

【讨论】:

    猜你喜欢
    • 2021-05-07
    • 1970-01-01
    • 2019-10-27
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多