python - 如何解决google colab中的 "No module named '工具''?

标签 python pytorch google-colaboratory

我正在尝试按照本教程在我的数据中应用 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“没有名为“tools”的模块”。

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

pyserial: No module named tools

ModuleNotFoundError: No module named 'tools.nnwrap'

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

请帮忙!

最佳答案

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

关于python - 如何解决google colab中的 "No module named '工具''?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57612610/

相关文章:

jupyter-notebook - 在 Google Colab 上安装 jupyter-contrib-nbextension

python - pytorch运行时错误: CUDA error: device-side assert triggered

python 枕头 : how to produce 3-channel image from 1-channel image?

python - 为 PyTorch 中的简单神经网络增加训练和测试精度

python - 在 PyTorch 中用矢量替换对角线元素

python - 梯度如何通过随机样本反向传播?

python - 如何通过代码清除 Google Colab 中的输出?

python - pandas 删除括号,字符串中的内部内容保留一个空格

Python 对列表项的唯一列表进行排序

python - 如何更改 __builtins__ 模块变量?