defi/dapp/lp/ido/dao智能合约系统开发(开发逻辑)及方案丨源码成品

简介: This file will show you how to quantize your network with PPQ

This file will show you how to quantize your network with PPQ

  You should prepare your model and calibration dataset as follow:

  ~/working/model.onnx<--your model

  ~/working/data/.npy or~/working/data/.bin<--your dataset

  if you are using caffe model:

  ~/working/model.caffemdoel<--your model

  ~/working/model.prototext<--your model

  ###MAKE SURE YOUR INPUT LAYOUT IS[N,C,H,W]or[C,H,W]###

  quantized model will be generated at:~/working/quantized.onnx

  """

  from ppq import*

  from ppq.api import*

  import os

  #modify configuration below:

  WORKING_DIRECTORY='working'#choose your working directory

  TARGET_PLATFORM=TargetPlatform.PPL_CUDA_INT8#choose your target platform

  MODEL_TYPE=NetworkFramework.ONNX#or NetworkFramework.CAFFE

  INPUT_LAYOUT='chw'#input data layout,chw or hwc

  NETWORK_INPUTSHAPE=[1,3,224,224]#input shape of your network

  CALIBRATION_BATCHSIZE=16#batchsize of calibration dataset

  EXECUTING_DEVICE='cuda'#'cuda'or'cpu'.

  REQUIRE_ANALYSE=False

  DUMP_RESULT=False#是否需要Finetuning一下你的网络

  #SETTING对象用于控制PPQ的量化逻辑

  #当你的网络量化误差过高时,你需要修改SETTING对象中的参数进行特定的优化

  SETTING=UnbelievableUserFriendlyQuantizationSetting(

  platform=TARGET_PLATFORM,finetune_steps=2500,

  finetune_lr=1e-3,calibration='kl',#【改】量化算法可选'kl','pecentile','mse'

  equalization=True,non_quantable_op=None)

  SETTING=SETTING.convert_to_daddy_setting()

  print('正准备量化你的网络,检查下列设置:')

  print(f'WORKING DIRECTORY:{WORKING_DIRECTORY}')

  print(f'TARGET PLATFORM:{TARGET_PLATFORM.name}')

  print(f'NETWORK INPUTSHAPE:{NETWORK_INPUTSHAPE}')

  print(f'CALIBRATION BATCHSIZE:{CALIBRATION_BATCHSIZE}')

  #此脚本针对单输入模型,输入数据必须是图像数据layout:[n,c,h,w]

  #如果你的模型具有更复杂的输入格式,你可以重写下面的load_calibration_dataset函数

  #请注意,任何可遍历对象都可以作为PPQ的数据集作为输入

  dataloader=load_calibration_dataset(

  directory=WORKING_DIRECTORY,

  input_shape=NETWORK_INPUTSHAPE,

  batchsize=CALIBRATION_BATCHSIZE,

  input_format=INPUT_LAYOUT)

  print('网络正量化中,根据你的量化配置,这将需要一段时间:')

  quantized=quantize(

  working_directory=WORKING_DIRECTORY,setting=SETTING,

  model_type=MODEL_TYPE,executing_device=EXECUTING_DEVICE,

  input_shape=NETWORK_INPUTSHAPE,target_platform=TARGET_PLATFORM,

  dataloader=dataloader,calib_steps=32)

相关文章
|
安全 区块链
defi丨dapp智能合约代币系统开发(开发案例)/需求详细/逻辑方案/项目源码
The development of the Defi single and dual currency pledge liquidity mining system requires the following steps: requirement analysis, system design, contract writing, front-end and back-end development, testing and deployment. Firstly, conduct a comprehensive requirement analysis of the system&#39;s f
|
6月前
|
安全 区块链
dapp/defi智能合约质押分红系统开发详细功能/案例步骤/需求逻辑/源码指南
Developing a DApp/DeFi smart contract staking dividend system involves multiple technical and functional requirements. The following are possible detailed development steps and functional requirements for your reference
|
6月前
|
存储 安全 测试技术
DAPP|LP|DeFi质押项目系统开发细节方案
智能合约产生价值的最基本前提是有一个强有力的底层介质用于储存
|
6月前
|
存储 供应链 安全
DAPP质押LP算力池模式系统开发方案功能
智能合约的基本过程可以简单概括为部署、执行和终止。
|
安全 前端开发 JavaScript
DeFi/ IDO /DAO/DAPP/LP/Swap代币兑换底池交易所项目系统开发步骤需求丨案例项目丨方案逻辑丨详细流程丨源码部署
Requirement analysis: Clarify project objectives, functional requirements, and business models. Understand the different components of the DeFi ecosystem, such as IDO (initial issuance), DAO (decentralized autonomous organization), DApp (decentralized application), LP (liquidity provider), and Swap
|
区块链 开发者
dapp丨defi丨lp丨ido丨dao智能合约系统开发
Web3生态系统的核心是智能合约和去中心化应用程序
|
存储 机器学习/深度学习 算法
深入分析defi/dao/ido/dapp/lp/swap交易所代币合约项目系统开发(逻辑方案)/成熟技术/案例详细/源码部署
区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式
|
区块链 安全
dapp丨defi丨lp智能合约系统开发规则玩法/逻辑说明/项目案例/方案设计/源码程序
Single and dual currency pledge mining is an economic incentive mechanism based on cryptocurrency projects. Under this mechanism, participants can obtain mining rewards by pledging a single cryptocurrency or a pair of cryptocurrencies (dual currency) they hold.
|
存储 安全 测试技术
dapp丨lp丨defi发行代币合约系统开发项目详细/案例分析/成熟技术/源码逻辑
  去中心化应用:区块链不仅仅是一种存储和传输数据的技术,还可以支持构建去中心化应用(DApp)。通过智能合约等技术,可以在区块链上实现自动化的、不需要中间人的应用程序。