We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,有个问题想请教以下:
#搭建CNN+Capsule分类模型 input_image = Input(shape=(None,None,1)) cnn = Conv2D(64, (3, 3), activation='relu')(input_image) cnn = Conv2D(64, (3, 3), activation='relu')(cnn) cnn = AveragePooling2D((2,2))(cnn) cnn = Conv2D(128, (3, 3), activation='relu')(cnn) cnn = Conv2D(128, (3, 3), activation='relu')(cnn) cnn = Reshape((-1, 128))(cnn) capsule = Capsule(10, 16, 3, True)(cnn) output = Lambda(lambda x: K.sqrt(K.sum(K.square(x), 2)), output_shape=(10,))(capsule) model = Model(inputs=input_image, outputs=output) model.compile(loss=lambda y_true,y_pred: y_true*K.relu(0.9-y_pred)**2 + 0.25*(1-y_true)*K.relu(y_pred-0.1)**2, optimizer='adam', metrics=['accuracy'])
在这个模型中,output = Lambda(lambda x: K.sqrt(K.sum(K.square(x), 2)), output_shape=(10,))(capsule) 这一行操作的输入capsule的的结构是[batch_size,num_capsule,dim_capsule]. output执行的含义是:
我的理解,这个操作是将capsule的每一个分量转换成可能性(概率),那么这个地方是否可以换乘求和或者求平均呢? 采用是否有其他的含义呢?
谢谢了.
The text was updated successfully, but these errors were encountered:
那是你没有通读capsule整个流程和思想。 capsule就是希望向量的模长为0~1之间,代表着激活程度(概率值),所以用向量的模长(也就是K.sqrt(K.sum(K.square(x), 2)))是最自然的
K.sqrt(K.sum(K.square(x), 2))
Sorry, something went wrong.
明白了,十分感谢.@bojone
No branches or pull requests
你好,有个问题想请教以下:
在这个模型中,output = Lambda(lambda x: K.sqrt(K.sum(K.square(x), 2)), output_shape=(10,))(capsule) 这一行操作的输入capsule的的结构是[batch_size,num_capsule,dim_capsule]. output执行的含义是:
我的理解,这个操作是将capsule的每一个分量转换成可能性(概率),那么这个地方是否可以换乘求和或者求平均呢? 采用是否有其他的含义呢?
谢谢了.
The text was updated successfully, but these errors were encountered: