微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

导入模型时没有名为 hyppo._utils 的模块

如何解决导入模型时没有名为 hyppo._utils 的模块

我的问题是在尝试导入 DCSBM 模型时:

代码

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import hyppo 


from hyppo.time_series import _utils as _utils 
from graspy.embed import AdjacencySpectralEmbed
from graspy.models import DCSBMEstimator 
from graspy.models import EREstimator 
from graspy.models import SBMEstimator

from graspy.models.sbm import _block_to_full,_get_block_indices
from graspy.simulations import er_np,sbm

错误

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-33-287386449480> in <module>()
      8 from hyppo.time_series import _utils as _utils
      9 from graspy.embed import AdjacencySpectralEmbed
---> 10 from graspy.models import DCSBMEstimator
     11 from graspy.models import EREstimator
     12 from graspy.models import SBMEstimator

2 frames
/usr/local/lib/python3.7/dist-packages/graspy/inference/latent_distribution_test.py in <module>()
     26 from sklearn.metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS
     27 from hyppo.ksample import KSample
---> 28 from hyppo._utils import gaussian
     29 
     30 _VALID_disTANCES = list(PAIRED_disTANCES.keys())

ModuleNotFoundError: No module named 'hyppo._utils'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package,you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies,click the
"Open Examples" button below.

我认为 hyppo._utils 不存在并且已被 hyppo.time_series 替换,并且在该文件夹中存在所需的 _utils 包。

我们如何解决这个问题?

我只是想运行教程:https://docs.neurodata.io/notebooks/pedigo/graspologic/2020/09/24/latent_model_tutorial.html

在 Google colab 上运行

这一行 from hyppo.time_series import _utils as _utils 是我试图解决该问题时添加的,但不起作用。

解决方法

看起来您使用的是旧版本的软件包 - 现在称为“graspologic”。如果您 pip install graspologicfrom graspologic.models import DCSBMEstimator 应该可以正常工作。只需将代码中所有显示“graspy”的内容替换为“graspologic”即可。

我们也很乐意回答有关 github 问题的问题! (我是为该软件包做出贡献的人之一)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。