小编仲耀晖*_*仲耀晖的帖子

导入错误:没有名为路径的模块

我的脚本中有这一行:

from path import Path
Run Code Online (Sandbox Code Playgroud)

但我遇到了这个错误

ImportError: No module named path
Run Code Online (Sandbox Code Playgroud)

但是,我已经在我的系统中安装了 path.py,当我from path import Path在终端中用 python3 编写时没有问题。这很奇怪。

python path python-3.x

5
推荐指数
2
解决办法
1万
查看次数

在 TensorFlow 中使用多个 GPU 来推断 pb 模型

我使用带有 8 个 Titan X 的服务器,试图比使用单个 GPU 更快地预测图像。我像这样加载 PB 模型:

model_dir = "./model"
    model = "nasnet_large_v1.pb"
    model_path = os.path.join(model_dir, model)
    model_graph = tf.Graph()
    with model_graph.as_default():
        with tf.gfile.GFile(model_path, 'rb') as f:
            graph_def = tf.GraphDef()
            graph_def.ParseFromString(f.read())
            _ = tf.import_graph_def(graph_def, name='')
            input_layer = model_graph.get_tensor_by_name("input:0")
            output_layer = model_graph.get_tensor_by_name('final_layer/predictions:0')
Run Code Online (Sandbox Code Playgroud)

然后我开始./data_input像这样迭代目录中的文件:

with tf.Session(graph = model_graph, config=config) as inference_session:
        # Initialize session
        initializer = np.zeros([1, 331, 331, 3])
        print("Initialing session...")
        inference_session.run(output_layer, feed_dict={input_layer: initializer})
        print("Done initialing.")

        # Prediction
        file_list = []
        processed_files = []

        for path, …
Run Code Online (Sandbox Code Playgroud)

gpu python-3.x tensorflow

5
推荐指数
1
解决办法
1419
查看次数

标签 统计

python-3.x ×2

gpu ×1

path ×1

python ×1

tensorflow ×1