nn_bandit.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:DNN_Recsys_demo 作者: ShouldChan 项目源码 文件源码
def choose_arm(x, experts, explore):
    n_arms = len(experts)
    # make predictions
    preds = [expert.predict(x) for expert in experts]
    # get best arm
    arm_max = np.nanargmax(preds)
    # create arm selection probabilities
    P = [(1-explore)*(arm==arm_max) + explore/n_arms for arm in range(n_arms)]
    # select an arm
    chosen_arm = np.random.choice(np.arange(n_arms), p=P)
    pred = preds[chosen_arm]
    return chosen_arm, pred
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号