def _jdc_loss_func0( md ): eps = 1e-6 a8_node = md.out_nodes_[0] # shape: (n_songs, n_chunk, n_out) b8_node = md.out_nodes_[1] # shape: (n_songs, n_chunk, n_out) gt_node = md.gt_nodes_[0] # shape: (n_songs, n_out) n_chunks = a8_node.shape[1] z0_node = md.in_nodes_[1] # shape: (n_songs, n_chunks) a8_node = a8_node * z0_node[:,:,None] b8_node = b8_node * z0_node[:,:,None] a8_node = T.clip( a8_node, eps, 1-eps ) b8_node = T.clip( b8_node, eps, 1-eps ) # clip to avoid numerical underflow uni_mu = b8_node / K.sum( b8_node, axis=1 )[:,None,:] jdc_pd = K.sum( a8_node * uni_mu, axis=1 ) jdc_pd = T.clip( jdc_pd, eps, 1-eps ) loss_2d = K.binary_crossentropy( jdc_pd, gt_node ) return K.mean( K.sum( loss_2d, axis=1 ) )
def mean_pool(input): return K.mean(input, axis=(2, 3))
def mean_pool(input): return K.mean(input, axis=1)