如何解决异常-带有SDK 2.0的Movidius Stick(1版)-异常:Status.INVALID_DATA_LENGTH

时间:2019-05-29 09:00:06

标签: tensorflow keras intel ncsdk movidius

我与Keras一起训练了自定义网络。然后,使用脚本将我的keras模型转换为tensorflow,并使用mvnCCompiler获得相关的图形文件。 当我运行推断时,使用 graph.allocate_with_fifos graph.queue_inference_with_fifo_elem 指定输入张量,会出现以下错误

异常:Status.INVALID_DATA_LENGTH E:[0] ncFifoWriteElem:2608输入张量长度(59040)与期望值(19680)不匹配

输入张量为(60,41,2)

我做了很多尝试而没有找到解决方案。 有人可以帮我吗?

非常感谢

 features = extract_features(parent_dir, sub_dirs)

    X_test = features

    print(X_test.size)
    print(X_test.shape)

    from mvnc import mvncapi

    # Get a list of valid device identifiers
    device_list = mvncapi.enumerate_devices()

    # Create a Device instance for the first device found
    device = mvncapi.Device(device_list[0])

    # Open communication with the device
    device.open()

    # Create a Graph
    graph = mvncapi.Graph('')

    graph_filepath='graph2.graph'

    with open(graph_filepath, 'rb') as f:
        graph_buffer = f.read()

    input_fifo, output_fifo = graph.allocate_with_fifos(device, graph_buffer)

    graph.queue_inference_with_fifo_elem(input_fifo, output_fifo, X_test.astype('float32'), 'userobj')

    # the result to the output Fifo
    output, userobj = output_fifo.read_elem()
    print('Predicted:', output.argmax())

    # Deallocate and destroy the graph handle and fifo handles, close the device, and destroy the device handle
    input_fifo.destroy()
    output_fifo.destroy()
    graph.destroy()
    device.close()

0 个答案:

没有答案