当前位置: 首页>>代码示例>>Python>>正文


Python Logger.to_string方法代码示例

本文整理汇总了Python中utils.Logger.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.to_string方法的具体用法?Python Logger.to_string怎么用?Python Logger.to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Logger的用法示例。


在下文中一共展示了Logger.to_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: P

# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import to_string [as 别名]
                # Positive P(s1 -a-> s1.a)
                count = exc if a == user_profile + 1 else 1
                new_count = args.alpha * count if not args.norm else args.alpha * count / total_count
                assert (args.alpha * count < total_count), "AssertionError: alpha parameter too large. Probabilities out of range."
                s2 = get_next_state_id(s1, a)
                transitions_str += "%d\t%d\t%d\t%s\n" % (s1, a, s2, new_count)
                # Negative P(s1 -a-> s1.b), b!= a
                beta = (total_count - args.alpha * count) / (total_count - count)
                # For every s2, sample T(s1, a, s2)
                for s2_link in actions:
                    if (s2_link != a):
                        s2 = get_next_state_id(s1, s2_link)
                        count = exc if s2_link == user_profile + 1 else 1
                        transitions_str += "%d\t%d\t%d\t%s\n" % (s1, a, s2, beta * count if not args.norm else beta * count / total_count)
                # If buffer overflows, write in file
                if len(transitions_str) > buffer_size:
                    f.write(bytes(transitions_str.encode("UTF-8")) if args.zip else transitions_str)
                    transitions_str = ""
        # Environment change
        transitions_str += "\n"
    f.write(bytes(transitions_str.encode("UTF-8")) if args.zip else transitions_str)
    f.close()

    with open("%s.summary" % output_base, 'w') as f:
        f.write("%d States\n%d Actions (Items)\n%d user profiles\n%d history length\n%d product clustering level\n\n%s" % (n_states, n_items, n_users, args.history, args.nactions, logger.to_string()))

    ###### 6. Summary
    print("\n\n\033[92m-----> End\033[0m")
    print("   Output directory: %s" % output_base)
    # End
开发者ID:ameroyer,项目名称:ReCA,代码行数:32,代码来源:prepare_synth.py


注:本文中的utils.Logger.to_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。