Kaggle competition: Google Landmark Recognition Challenge
<SOS> metric: GoogleGlobalAP Kaggle data source: landmark-recognition-challenge<load_pretrained>
%matplotlib inline
for i in range(7):
model_path = f'.. /input/pretrained-bert/bert-{i}.h5'
model = bert_model()
model.load_weights(model_path)
 models.append(model )<load_pretrained>
base_dir = '.. /input/'
train_df = pd.read_csv(os.path.join(base_dir, 'train.csv'))
test_df = pd.read_csv(os.path.join(base_dir, 'test.csv'))
train_df.sample(3 )
for i in range(7):
model_path = f'.. /input/bert-base-tf2-0-training/bert-{i}.h5'
model = bert_model()
model.load_weights(model_path)
 models.append(model )<define_variables>
submit_df = pd.read_csv(os.path.join(base_dir, 'sample_submission.csv'))
def_guess = train_df['landmark_id'].value_counts() /train_df['landmark_id'].value_counts().sum()
def_guess.index[0], def_guess.values[0]
test_predictions = []<predict_on_test>
submit_df['landmarks'] = '%d %2.2f' %(def_guess.index[0], def_guess.values[0])
 submit_df.to_csv('submission.csv', index=False)
 submit_df.sample(2 )
for model in models:
test_predictions.append(model.predict(test_inputs, batch_size=8))<prepare_output>
np.random.seed(2018)
 r_idx = lambda : np.random.choice(def_guess.index, p = def_guess.values )
<load_pretrained><EOS> 
%%time
r_score = lambda idx: '%d %2.4f' %(def_guess.index[idx], def_guess.values[idx])
 submit_df['landmarks'] = submit_df.id.map(lambda _: r_score(r_idx()))
submit_df.to_csv('rand_submission.csv', index=False)
 submit_df.sample(2 )