가장 순진한 구현에서는 데이터를 바꿀 수 있으며 설명 된 바를 정확히 알 수 있습니다 : "연속적인 각 트리플에 대한 확률".
당신은 (batch_size,27)
모양 (27 개) 클래스와 출력을 가지고 그것을 바꿀 :
model.add(Reshape((9,3)))
model.add(Activation('softmax'))
테이크 케어뿐만 아니라 당신의 y_true
데이터를 바꿀 수 있습니다. 그들은 대략 정적이 있다면 당신은 아마 (그 위치에 따라 insterest의 9 점을 분리하는 것, 더 정교한 솔루션에서
model.add(Reshape((27,))
: 또는 원형을 복원 모델의 또 다른 모양 변경을 추가 위치)를 만들고 병렬 경로를 만듭니다. 예를 들어, 9 개의 위치가 균등 한 간격의 사각형이라고 가정하고 해당 세그먼트에 대해 동일한 넷 및 클래스를 사용하려고한다고 가정합니다.
inputImage = Input((height,width,channels))
#supposing the width and height are multiples of 3, for easiness in this example
recHeight = height//3
recWidth = width//3
#create layers here without calling them
someConv1 = Conv2D(...)
someConv2 = Conv2D(...)
flatten = Flatten()
classificator = Dense(..., activation='softmax')
outputs = []
for i in range(3):
for j in range(3):
fromH = i*recHeight
toH = fromH + recHeight
fromW = j*recWidth
toW = fromW + recWidth
imagePart = Lambda(
lambda x: x[:,fromH:toH, fromW:toW,:],
output_shape=(recHeight,recWidth,channels)
)(inputImage)
#using the same net and classes for all segments
#if this is not true, create new layers here instead of using the same
output = someConv1(imagePart)
output = someConv2(output)
output = flatten(output)
output = classificator(output)
outputs.append(output)
outputs = Concatenate()(outputs)
model = Model(inputImage,outputs)