0
ケラスでは、PointNet(https://arxiv.org/pdf/1612.00593.pdf)のバリエーションを実装したいと考えていましたが、文脈ベクトル(g)を可変回数繰り返して問題を解決していますコンテキスト(前)がない前のレイヤーと並んでいます。私は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)
これは私が思いついたラムダ定義です。
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: 'をパック' OPの '値' に渡されたリスト内テンソルはすべて一致しないタイプ[INT32、INT32]を持っています。
UPDATE:
だから私は、次の手順を実行して、エラーを与えないように層を得ることができた:
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'