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


Python IPython.embed方法代码示例

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


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

示例1: test

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def test():
    from tqdm import trange
    import cv2
    print('debug mode '*10 )
    args = parse_args()
    cfg = Config.fromfile(args.config)
    cfg.gpus = 1

    dataset = build_dataset(cfg.data.train)
    embed(header='123123')
    # def visual(i):
    #     img = dataset[i]['img'].data
    #     img = img.permute(1,2,0) + 100
    #     img = img.data.cpu().numpy()
    #     cv2.imwrite('./trash/resize_v1.jpg',img)

    # embed(header='check data resizer') 
开发者ID:xieenze,项目名称:PolarMask,代码行数:19,代码来源:train.py

示例2: extract_prologue_call_site_signature

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def extract_prologue_call_site_signature(self, state):
        """
        extract the data flow signature e.g., rdx rsi rdi at the indirect call in the prologue function
        :param state: the state
        :return: dict of interested register values
        """
        print('[+] extracting prologue call site signatures...')
        signature = dict()
        signature['rdx'] = state.regs.rdx
        signature['rsi'] = state.regs.rsi
        signature['rdi'] = state.regs.rdi
        print('rdx', state.regs.rdx)
        print('rsi', state.regs.rdi)
        print('rdi', state.regs.rdi)
        # import IPython; IPython.embed()
        return signature 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:18,代码来源:_prologue_gadget.py

示例3: enter_prologue_callback

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def enter_prologue_callback(self, state):
        """
        this is a bp on the first instruction of the prologue gadget
        we add a bp over call instruction to handle future indirect call
        TODO: BUG here: we did not consider the indirect jump
        :param state:
        :return:
        """
        self.reach_current_prologue_entry = True
        print(colorama.Fore.RED + 'enter prologue gadget' + colorama.Style.RESET_ALL)
        if not self.is_dfs_search_routine:
            state.inspect.remove_breakpoint("call", self.first_fork_site_bp)
            print('[+] removed the call bp at the first fork site..')
        #
        self.bp_enforce_prologue_to_copy_to_user = state.inspect.b("call", when=angr.BP_BEFORE
                                                                   , action=self.enforce_prologue_to_copy_to_user)
        print('[+] enforced a bp on call for disclosure')
        #import IPython; IPython.embed()
        return 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:21,代码来源:_prologue_gadget.py

示例4: enforce_indirect_jump_to_disclosure_gadget

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def enforce_indirect_jump_to_disclosure_gadget(self, state):
        """
        this function is actually a callback or bp over unconstrained jmp instruction
        :param state:
        :return:
        """
        if state.regs.rip.symbolic:
            print('trying to extract signature at prologue indirect jump to copy_from_user')
            print(colorama.Fore.RED +'jmp instruction at:', hex(state.history.addr) + colorama.Style.RESET_ALL)
            # self.dump_reg(state)
            print(colorama.Fore.RED + '[+] extracting runtime data flow signature for pairing with disclosure gadget'
                  + colorama.Style.RESET_ALL)
            data_signatures = self.extract_prologue_call_site_signature(state)
            self.current_prologue_signature = data_signatures
            print(colorama.Fore.RED + '[!] removing bp_enforce_prologue_to_copy_to_user)' + colorama.Style.RESET_ALL)
            state.inspect.remove_breakpoint('call', self.bp_enforce_prologue_to_copy_to_user)
            # embed()
        else:
            print('rip is not symbolic, this should never happen')
            embed()
        return 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:23,代码来源:_prologue_gadget.py

示例5: enforce_prologue_to_copy_to_user

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def enforce_prologue_to_copy_to_user(self, state):
        """
        this function is actually a callback or bp over unconstrained call instructions
        :param state:
        :return:
        """
        if state.regs.rip.symbolic:
            print('trying to extract signature at prologue indirect call to copy_from_user')
            print('Call target address :', state.inspect.function_address)
            # self.dump_reg(state)  # dump registers for debug purpose
            print(colorama.Fore.RED + '[+] extracting runtime data flow signature for pairing with disclosure gadget'
                  + colorama.Style.RESET_ALL)
            data_signatures = self.extract_prologue_call_site_signature(state)
            self.current_prologue_signature = data_signatures
            print(colorama.Fore.RED + '[!] removing bp_enforce_prologue_to_copy_to_user)' + colorama.Style.RESET_ALL)
            state.inspect.remove_breakpoint('call', self.bp_enforce_prologue_to_copy_to_user)
            # embed()
        else:
            print('rip is not symbolic, we are not removing this enforcement until we finding one')
            # embed()
        return 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:23,代码来源:_prologue_gadget.py

示例6: install_extra_module

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def install_extra_module(self, s):
        if self.extra_module_base is not None:
            try:
                extra_module_base = self.extra_module_base
                extra_module_size = self.extra_module_size
                num_of_pages = extra_module_size / 4096 + 1
                print('extra module is at memory location %x of size %x' % (extra_module_base, extra_module_size))
                for i in range(num_of_pages):
                    addr = extra_module_base + i * 4096
                    con = self.statebroker.get_a_page(self.r, addr)
                    if con is not None:
                        print('successfully get a page at:', hex(addr))
                        self.set_loader_concret_memory_region(s, addr, con, 4096)
                    else:
                        input('failed to get a page')
                print('Finished installing extra modules')
            except TypeError as e:
                print(e)
                traceback.print_exc()
                embed()
        else:
            print('do not need to print extra module')
        return 
开发者ID:ww9210,项目名称:kepler-cfhp,代码行数:25,代码来源:_concrete_state.py

示例7: _start_repl

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def _start_repl(api):
    # type: (Iota) -> None
    """
    Starts the REPL.
    """
    _banner = (
      'IOTA API client for {uri} ({testnet}) initialized as variable `api`.\n'
      'Type `help(api)` for list of API commands.'.format(
        testnet = 'testnet' if api.testnet else 'mainnet',
        uri     = api.adapter.get_uri(),
      )
    )

    try:
      # noinspection PyUnresolvedReferences
      import IPython
    except ImportError:
      # IPython not available; use regular Python REPL.
      from code import InteractiveConsole
      InteractiveConsole(locals={'api': api}).interact(_banner)
    else:
      # Launch IPython REPL.
      IPython.embed(header=_banner) 
开发者ID:llSourcell,项目名称:IOTA_demo,代码行数:25,代码来源:repl.py

示例8: shell

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def shell(scope):
    if isinstance(scope, ga.account.Profile):
        profile = scope
        account = profile.account
        metrics = profile.core.metrics
        dimensions = profile.core.dimensions
        core = profile.core.query
        realtime = profile.realtime.query
        print('* global variables: profile, account, metrics, dimensions')
        print('* build queries with the `core` and `realtime` variables')
        print("  e.g. `core.metrics('pageviews').daily('yesterday').values`\n")
    else:
        print('* global variables: scope')
        print('  (provide webproperty and/or profile for additional shortcuts)\n')

    embed(local=locals()) 
开发者ID:debrouwere,项目名称:google-analytics,代码行数:18,代码来源:shell.py

示例9: local_test

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def local_test(self, test_dataloader):
        self.model.eval()
        test_loss = test_acc = test_total = 0.
        with torch.no_grad():
            for x, y in test_dataloader:
                # print("test")
                # from IPython import embed
                # embed()
                if self.gpu:
                    x, y = x.cuda(), y.cuda()

                pred = self.model(x)
                loss = criterion(pred, y)
                _, predicted = torch.max(pred, 1)
                correct = predicted.eq(y).sum()

                test_acc += correct.item()
                test_loss += loss.item() * y.size(0)
                test_total += y.size(0)

        return test_acc, test_loss 
开发者ID:lx10077,项目名称:fedavgpy,代码行数:23,代码来源:worker.py

示例10: cmd_console

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def cmd_console(args):
    import code
    import platform

    d = u2.connect(args.serial)
    model = d.shell("getprop ro.product.model").output.strip()
    serial = d.serial
    try:
        import IPython
        from traitlets.config import get_config
        c = get_config()
        c.InteractiveShellEmbed.colors = "neutral"
        IPython.embed(config=c, header="IPython -- d.info is ready")
    except ImportError:
        _vars = globals().copy()
        _vars.update(locals())
        shell = code.InteractiveConsole(_vars)
        shell.interact(banner="Python: %s\nDevice: %s(%s)" %
                       (platform.python_version(), model, serial)) 
开发者ID:openatx,项目名称:uiautomator2,代码行数:21,代码来源:__main__.py

示例11: invBN

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def invBN(self, arr, Y_name):
        if isinstance(arr, int) or len(self.bns) == 0 or len(self.affines) == 0:
            return arr
        interstellar = Y_name.split('_')[0]
        for i in self.bottom_names[interstellar]:
            if i in self.bns and 'branch2c' in i:
                bn = i
                break
        for i in self.affines:
            if self.layer_bottom(i) == bn:
                affine = i
                break

        if 1: print('inverted bn', bn, affine, Y_name)
        mean, std, k, b = self.getBNaff(bn, affine)
        # (y - mean) / std * k + b
        #return (arr - b) * std / k + mean
        return arr * std / k
        #embed() 
开发者ID:yihui-he,项目名称:channel-pruning,代码行数:21,代码来源:net.py

示例12: YYT

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def YYT(Y, n_components=None, DEBUG=False):
    """
    Param:
        Y: n x d
        n_components: use 'mle' to guess
    Returns:
        P: d x d'
        QT: d' x d
    """
    newdata = Y.copy()
    model = PCA(n_components=n_components)

    if len(newdata.shape) != 2:
        newdata = newdata.reshape((newdata.shape[0], -1))
    #TODO center data
    model.fit(newdata)
    if DEBUG: from IPython import embed; embed()

    return model.components_.T, model.components_

#def GSVD(Z, Y):
#    NotImplementedError
#    return [U,V,X,C,S] 
开发者ID:yihui-he,项目名称:channel-pruning,代码行数:25,代码来源:decompose.py

示例13: do

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def do(self, which_callback, *args):

        if not self.sig_raised:
            return
        self.sig_raised = False

        env = None
        if self.use_main_loop_run_caller_env:
            frame = sys._getframe()
            while frame:
                if frame.f_code is self.main_loop.run.func_code:
                    env = frame.f_back.f_locals
                    break
                frame = frame.f_back

        IPython.embed(user_ns=env) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:18,代码来源:embed_ipython.py

示例14: save_model

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def save_model(self):

        if self.iter_num==-7:
            print("Error: MUST SPECIFY ITER_NUM FOR SAVER...")
            import IPython
            IPython.embed()

        # save the model under current iteration number
        # but also update the finalModel.ckpt too
        save_path1 = self.tf_saver.save(
            self.sess, self.save_dir + '/models/model_aggIter' + str(
                self.iter_num) + '.ckpt')
        save_path2 = self.tf_saver.save(
            self.sess, self.save_dir + '/models/finalModel.ckpt')
        print("Model saved at ", save_path1)

    ############################################################################################
    ##### The following 2 saves together represent a single "iteration"
    ########## (train model) + (collect new rollouts with that model) = a single "iteration"
    ############################################################################################ 
开发者ID:google-research,项目名称:pddm,代码行数:22,代码来源:saver.py

示例15: sample

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import embed [as 别名]
def sample(self, vis = False, stop = False):
        """
        Samples probabilities of success from the given values
        """
        #samples = np.random.beta(self.posterior_alphas_, self.posterior_betas_)
        samples = scipy.stats.beta.rvs(self.posterior_alphas_, self.posterior_betas_)
        if stop:
            IPython.embed()
        if vis:
            print('Samples')
            print(samples)
            print('Estimated mean')
            print((BetaBernoulliModel.beta_mean(self.posterior_alphas_, self.posterior_betas_)))
            print('At best index')
            print((BetaBernoulliModel.beta_mean(self.posterior_alphas_[21], self.posterior_betas_[21])))
        return samples 
开发者ID:lianghongzhuo,项目名称:PointNetGPD,代码行数:18,代码来源:models.py


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