小编azm*_*ath的帖子

TensorFlow TypeError:传递给参数输入的值具有DataType uint8,不在允许值列表中:float16,float32

我想在过去的3天里让一个简单的CNN去训练.

首先,我设置了一个输入管道/队列配置,从目录树中读取图像并准备批处理.

我在这个链接上得到了这个代码.所以,我现在有了train_image_batchtrain_label_batch ,我需要提供给我的CNN.

train_image_batch, train_label_batch = tf.train.batch(
        [train_image, train_label],
        batch_size=BATCH_SIZE
        # ,num_threads=1
    )
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何.我正在使用此链接提供的CNN代码.

# Input Layer
input_layer = tf.reshape(train_image_batch, [-1, IMAGE_HEIGHT, IMAGE_WIDTH, NUM_CHANNELS])

# Convolutional Layer #1
conv1 = new_conv_layer(input_layer, NUM_CHANNELS, 5, 32, 2)

 # Pooling Layer #1
pool1 = new_pooling_layer(conv1, 2, 2)
Run Code Online (Sandbox Code Playgroud)

打印时的input_layer显示了这一点

张量("重塑:0",形状=(5,120,120,3),dtype = uint8)

下一行与TypeError崩溃; conv1 = new_conv_layer(...).new_conv_layer函数的主体如下所示

def new_conv_layer(input,              # The previous layer.
               num_input_channels, # Num. channels in prev. layer.
               filter_size,        # Width and height of each …
Run Code Online (Sandbox Code Playgroud)

python machine-learning neural-network tensorflow

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

cv2.calcOpticalFlowPyrLK 添加新点

问题

我正在尝试在 Lucas Kanade 光流跟踪方法中添加用于跟踪的自定义点。但是,在将自定义点插入自动计算的点数组后调用此函数时,出现断言失败错误。

OpenCV Error: Assertion failed ((npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0) in calcOpticalFlowPyrLK, file /opt/opencv-3.1.0/opencv/modules/video/src/lkpyramid.cpp, line 1114 
Traceback (most recent call last):
  File "/opt/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 1580, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/opt/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 964, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/opt/pycharm-community-2016.2.3/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/work/12_Kyloren/Repository/kyloren/firmware/Python/modules/kanade.py", line 45, in <module>
    p1, st, err = cv2.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, None, **lk_params)
cv2.error: /opt/opencv-3.1.0/opencv/modules/video/src/lkpyramid.cpp:1114: …
Run Code Online (Sandbox Code Playgroud)

python opencv numpy opticalflow cv2

3
推荐指数
1
解决办法
5008
查看次数