简体   繁体   English

无法解析导入“.utils”(reportMissingImports)

[英]Import ".utils" could not be resolved(reportMissingImports)

import torch
from torch import nn
from torch.nn import functional as F
from .utils import (
    round_filters,
    round_repeats,
    drop_connect,
    get_same_padding_conv2d,
    get_model_params,
    efficientnet_params,
    load_pretrained_weights,
    Swish,
    MemoryEfficientSwish,
    calculate_output_image_size
)

I tried a lot but I could'nt find the solution to fix this error我尝试了很多,但找不到解决此错误的解决方案

from .utils import round_filters

It gives error: relative import with no known parent package. See discussion for this in stackoverflow thread .它给出错误: relative import with no known parent package.请参阅stackoverflow 线程中的讨论。

You need to install EfficientNet-PyTorch package. About this package需要安装EfficientNet-PyTorch package。关于这个package

!pip install EfficientNet-PyTorch

And add parent package as from efficien.net_pytorch.utils import round_filters So your code should be并添加 parent package as from efficien.net_pytorch.utils import round_filters所以你的代码应该是

import torch
from torch import nn
from torch.nn import functional as F
from efficientnet_pytorch.utils import (
    round_filters,
    round_repeats,
    drop_connect,
    get_same_padding_conv2d,
    get_model_params,
    efficientnet_params,
    load_pretrained_weights,
    Swish,
    MemoryEfficientSwish,
    calculate_output_image_size
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入无法解析 Pylance(reportMissingImports) - Import could not be resolved Pylance(reportMissingImports) 导入“selenium”无法解析 Pylance(reportMissingImports) - Import "selenium" could not be resolved Pylance (reportMissingImports) "导入“spacy”无法解决 Pylance (reportMissingImports)" - Import "spacy" could not be resolved Pylance (reportMissingImports) 在 Mac 上的 VSCode 中无法解决导入“pygame”的 Pylance (reportMissingImports) 错误 - Import "pygame" could not be resolved Pylance (reportMissingImports) error in VSCode on mac 导入“flask_mysqldb”无法解析 Pylance(reportMissingImports) - Import "flask_mysqldb" could not be resolved Pylance(reportMissingImports) 导入“lab_utils_uni 无法解析 - Import "lab_utils_uni could not be resolved Google Colab 错误:导入“tensorflow.keras.models”无法解决(reportMissingImports) - Google Colab error: Import "tensorflow.keras.models" could not be resolved(reportMissingImports) 错误:导入 tensorflow.keras.backend 作为 K 无法解析 Pylance(reportMissingImports) - Error: import tensorflow.keras.backend as K could not be resolved Pylance(reportMissingImports) 导入“scipy.ndimage”无法解决 Pylance(reportMissingImports) - Import "scipy.ndimage" could not be resolvedPylance (reportMissingImports) "导入 web3 无法解决pylance(reportMissingImports)" - Import web3 could not be resolvedpylance(reportMissingImports)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM