Skip to content

Instantly share code, notes, and snippets.

View Chiang97912's full-sized avatar
🎯
Focusing

Peter Chiang Chiang97912

🎯
Focusing
View GitHub Profile
# -*- coding:utf-8 -*-
def MRR(ranked_list, ground_truth):
""" 平均倒排名 """
rr = 0.
for i in range(len(ranked_list)):
for j in range(len(ranked_list[i])):
# if ground_truth[i][0] == ranked_list[i][j]:
if ranked_list[i][j] in ground_truth[i]:
@Chiang97912
Chiang97912 / .vimrc
Last active September 25, 2023 10:05
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'flazz/vim-colorschemes'
Plugin 'ervandew/supertab'
Plugin 'davidhalter/jedi-vim'
Plugin 'mattn/emmet-vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
def attention_3d_block(inputs):
# inputs.shape = (batch_size, time_steps, input_dim)
input_dim = int(inputs.shape[2])
a = Permute((2, 1))(inputs)
a = Reshape((input_dim, TIME_STEPS))(a) # this line is not useful. It's just to know which dimension is what.
a = Dense(TIME_STEPS, activation='softmax')(a)
if SINGLE_ATTENTION_VECTOR:
a = Lambda(lambda x: K.mean(x, axis=1), name='dim_reduction')(a)
a = RepeatVector(input_dim)(a)
a_probs = Permute((2, 1), name='attention_vec')(a)