我希望在keras中实现PointNet的一个变体(https://arxiv.org/pdf/1612.00593.pdf),但我在重复上下文向量(g)的可变次数时遇到了麻烦,这样我就可以按行将其与缺少上下文的前一层连接起来(Pre)。我尝试了Repeat()和keras.backend.Tile()。
input = Input(shape=(None,3))
x = TimeDistributed(Dense(128, activation = 'relu'))(input)
pre = TimeDistributed(Dense(256, activation = 'relu'))(x)
g = GlobalMaxPooling1D()(pre)
x = Lambda(merge_on_single, output_shape=(None,512))([pre,g])
print(x.shape)这是我提出的lambda定义。
def merge_on_single(v):
#v[0] is variable length tensor, v[1] is the single vector
return Concatenate()([K.repeat(v[1],K.get_variable_shape(v[0])),v[0]])但是,会出现以下错误:
TypeError:列表中传递给'Pack‘Op的'values’的张量具有不完全匹配的类型int32,,int32。
更新:
因此,通过执行以下操作,我能够让这些层不给出错误:
input = Input(shape=(None,3))
num_point = K.placeholder(input.get_shape()[1].value, dtype=tf.int32)
#first global feature layer
x = TimeDistributed(Dense(512, activation = 'relu'))(input)
x = TimeDistributed(Dense(256, activation = 'relu'))(x)
g = GlobalMaxPooling1D()(x)
g = K.reshape(g,(-1,1,256))
g = K.tile(x, [1,num_point,1])
concat_feat = K.concatenate([x, g])但是现在,我得到了以下错误:
AttributeError: 'Tensor' object has no attribute '_keras_history'发布于 2017-06-16 18:05:33
我怀疑罪魁祸首是K.get_variable_shape(v[0])。由于v[0]的类型为int32 (正如您的错误所指定的那样),因此当您获得形状时,它将返回None。Concatenate希望所有输入都属于同一类型。
https://stackoverflow.com/questions/44583792
复制相似问题