TypeError:concat()为参数'axis'获取了多个值

Par*_*roi 7 python neural-network conv-neural-network tensorflow

这是我的卷积神经网络:

def convolutional_neural_network(frame):
    wts = {'conv1': tf.random_normal([5, 5, 3, 32]),
            'conv2': tf.random_normal([5, 5, 32, 64]),
            'fc': tf.random_normal([158*117*64 + 4, 128]),
            'out': tf.random_normal([128, n_classes])
            }
    biases = {'fc': tf.random_normal([128]),
                'out': tf.random_normal([n_classes])
            }

    conv1 = conv2d(frame, wts['conv1'])
    # print(conv1)
    conv1 = maxpool2d(conv1)
    # print(conv1)
    conv2 = conv2d(conv1, wts['conv2'])
    conv2 = maxpool2d(conv2)
    # print(conv2)
    conv2 = tf.reshape(conv2, shape=[-1,158*117*64])
    print(conv2)
    print(controls_at_each_frame)
    conv2 = tf.concat(conv2, controls_at_each_frame, axis=1)
    fc = tf.add(tf.matmul(conv2, wts['fc']), biases['fc'])

    output = tf.nn.relu(tf.add(tf.matmul(fc, wts['out']), biases['out']))

    return output
Run Code Online (Sandbox Code Playgroud)

哪里

frame = tf.placeholder('float', [None, 640-10, 465, 3])
controls_at_each_frame = tf.placeholder('float', [None, 4]) # [w, a, s, d] (1/0)
Run Code Online (Sandbox Code Playgroud)

是使用过的占位符.

我正在GTA San Andreas制造一辆自动驾驶汽车.我想要做的是连接framecontrols_at_each_frame进入单个层,然后将其发送到完全连接的层.当我跑我得到一个错误TypeError: concat() got multiple values for argument 'axis'

conv2 = tf.concat(conv2, controls_at_each_frame, axis=1)
Run Code Online (Sandbox Code Playgroud)

你能解释一下为什么会这样吗?

hau*_*ork 17

尝试

conv2 = tf.concat((conv2, controls_at_each_frame), axis=1).

注意我在这里指定要在括号内连接的两个帧.

  • 这就是我喜欢 stackoverflow 的原因。一分钟内得到答案。谢谢你。 (4认同)