Convolution2D 레이어로 고밀도 레이어의 출력을 융합하는 맞춤 레이어를 만들고 싶습니다.Keras - Convolution2D 레이어로 고밀도 레이어를 융합
는 아이디어 this paper에서 와서 여기에 네트워크의 :
융합 층이 조밀 한 텐서 (256
)와 Convolution2D 텐서 (256x28x28
)을 융합하려고합니다. 나는 새로운 사용자 층을 결국
: 여기
y_global => Dense layer output with shape 256
y_mid => Convolution2D layer output with shape 256x28x28
퓨전 프로세스에 대한 용지의 설명이다 : 여기에 대한 방정식이다 아래처럼 :
class FusionLayer(Layer):
def __init__(self, output_dim, **kwargs):
self.output_dim = output_dim
super(FusionLayer, self).__init__(**kwargs)
def build(self, input_shape):
input_dim = input_shape[1][1]
initial_weight_value = np.random.random((input_dim, self.output_dim))
self.W = K.variable(initial_weight_value)
self.b = K.zeros((input_dim,))
self.trainable_weights = [self.W, self.b]
def call(self, inputs, mask=None):
y_global = inputs[0]
y_mid = inputs[1]
# the code below should be modified
output = K.dot(K.concatenate([y_global, y_mid]), self.W)
output += self.b
return self.activation(output)
def get_output_shape_for(self, input_shape):
assert input_shape and len(input_shape) == 2
return (input_shape[0], self.output_dim)
는 내가 바로 __init__
및 build
방법을 가지고 있지만 출력이 언급 한 방정식과 같은 것입니다 수 있도록 call
층 y-mid
(256x28x28 치수)와 y_global
(256 dimesnions)을 연결하는 방법을 모르는 생각 위.
이 방정식을 call
방법으로 어떻게 구현할 수 있습니까? 너무 많은
감사합니다 ...
UPDATE : 성공적으로 2 층의 데이터를 통합 할 수있는 다른 방법은 정확히 방법은 논문에서 언급 할 필요가 없습니다 ... 또한 나를 위해 허용 하지만 적어도 받아 들일 수있는 출력을 반환해야합니다 ...