无模块名称索引

2024-04-25 12:24:28 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我对python和pyflan都是新手。我确实安装了pyflan并尝试运行它的测试示例。执行之后,我得到一个错误

from pyflann import FLANN
import numpy as np

dataset = np.array(
     [[1., 1, 1, 2, 3],
     [10, 10, 10, 3, 2],
     [100, 100, 2, 30, 1]
     ])
testset = np.array(
     [[1., 1, 1, 1, 1],
     [90, 90, 10, 10, 1]
     ])
flann = FLANN()
result, dists = flann.nn(dataset, testset, 2, 
algorithm="kmeans"branching=32, iterations=7, checks=16)
print (result)
print (dists)

dataset = np.random.rand(10000, 128)
testset = np.random.rand(1000, 128)
flann = FLANN()
result, dists = flann.nn(dataset, testset, 5, algorithm="kmeans", 
branching=32, iterations=7, checks=16)
print (result)
print (dists)

当我尝试执行上面的代码时,我会得到这样的结果

^{pr2}$

有人能回答这个问题吗,因为我的pyflan站点包中有这些文件,python版本是3.6。我应该如何继续运行上面的代码。在


Tags: importnpnnresultarrayalgorithmdatasetprint
1条回答
网友
1楼 · 发布于 2024-04-25 12:24:28

请参阅: https://github.com/primetang/pyflann/issues/1

显然,在为python3安装pyflann时,有一些语法错误需要修复。例如:

  • except Exception,e应改为except Exception as e

  • from foo import *应改为from .foo import *

  • exec需要括号。在
  • 在pyflann/io中/数据集.py你需要写from . import binary_datasetfrom . import dat_datasetfrom . import npy_dataset,和{},而不是{}等。在

相关问题 更多 >

    热门问题