最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

合約量化/量化合約/合約跟單/交易所系統(tǒng)開發(fā)實現(xiàn)技術(shù)及源碼詳細(xì)丨成熟穩(wěn)定版

2023-04-04 14:04 作者:bili_56252132691  | 我要投稿

  “定量交易”具有兩個含義:


  1、從狹義上講,它是指量化交易的內(nèi)容,將交易條件轉(zhuǎn)換為程序,并自動下訂單;


  2、從廣義上講,它是指系統(tǒng)的交易方法,是一種集成的交易系統(tǒng)。


  The characteristics of quantitative trading smart contracts:開發(fā)案例及源碼威:MrsFu123


  1.Publicization of contract content:Due to the operation of smart contracts on the blockchain,the contract content is made public.


  2.The content of the contract cannot be tampered with:it is also because it operates on the blockchain,and the content of the smart contract cannot be modified.


  3.Permanent operation:As long as the smart contract operates,the connected network nodes will maintain each other,and as long as the chain is still in place,it can operate permanently.


  4.More secure:Due to the code being the law,traders can confidently and safely buy and sell in an environment of distrust based on their trust in the code.


  5.More economical and efficient:Compared to traditional contracts,there are often conflicts in understanding contract terms,leading to disputes;Smart contracts effectively prevent conflicts through computational languages,rarely causing disputes,and the cost of reaching agreements is very low.On the smart contract,the results are displayed and immediately executed to take effect.Therefore,compared to traditional contracts,smart contracts have the advantages of economy and high efficiency.


  #載入ImageNet校準(zhǔn)數(shù)據(jù)集


  import os


  import torchvision.transforms as transforms


  from PIL import Image


  import numpy as np


  import torch


  input_path="xxxxxxx/xxxxx/x"#【改】數(shù)據(jù)集路徑


  for file in os.listdir(input_path):


  filename=os.fsdecode(file)


  img=Image.open(os.path.join(input_path,filename)).convert('RGB')


  scaler=transforms.Resize((224,224))


  normalize=transforms.Normalize(mean=[0.485,0.456,0.406],


  std=[0.229,0.224,0.225])


  to_tensor=transforms.ToTensor()


  device=torch.device("cpu")


  image=normalize(to_tensor(scaler(img))).unsqueeze(0).to(device)


  np.save(file=f'working/data/{filename[:-4]}',arr=image)#【改】注意圖像格式是.jpg還是.jpeg,.jpeg則filename[:-5]


  print('{}已完成,進(jìn)度{}/{}'.format(filename[:-5],os.listdir(input_path).index(file),len(os.listdir(input_path))))


  #如果你需要執(zhí)行量化后的神經(jīng)網(wǎng)絡(luò)并得到結(jié)果,則需要創(chuàng)建一個executor


  #這個executor的行為和torch.Module是類似的,你可以利用這個東西來獲取執(zhí)行結(jié)果


  #請注意必須在executor之前執(zhí)行此操作


  executor=TorchExecutor(graph=quantized)


  #output=executor.forword(input)


  #導(dǎo)出PPQ執(zhí)行網(wǎng)絡(luò)的所有中間結(jié)果,該功能是為了和硬件對比結(jié)果


  #中間結(jié)果可能十分龐大,因此PPQ將使用線性同余發(fā)射器從執(zhí)行結(jié)果中采樣


  #對了對比中間結(jié)果,硬件執(zhí)行結(jié)果也必須使用同樣的隨機(jī)數(shù)種子采樣


  #查閱ppq.util.fetch中的相關(guān)代碼以進(jìn)一步了解此內(nèi)容


  #查閱ppq.api.fsys中的dump_internal_results函數(shù)以確定采樣邏輯


  if DUMP_RESULT:


  dump_internal_results(


  graph=quantized,dataloader=dataloader,


  dump_dir=WORKING_DIRECTORY,executing_device=EXECUTING_DEVICE)


  #PPQ計算量化誤差時,使用信噪比的倒數(shù)作為指標(biāo),即噪聲能量/信號能量


  #量化誤差0.1表示在整體信號中,量化噪聲的能量約為10%


  #你應(yīng)當(dāng)注意,在graphwise_error_analyse分析中,我們衡量的是累計誤差


  #網(wǎng)絡(luò)的最后一層往往都具有較大的累計誤差,這些誤差是其前面的所有層所共同造成的


  #你需要使用layerwise_error_analyse逐層分析誤差的來源


  print('正計算網(wǎng)絡(luò)量化誤差(SNR),最后一層的誤差應(yīng)小于0.1以保證量化精度:')


  reports=graphwise_error_analyse(


  graph=quantized,running_device=EXECUTING_DEVICE,steps=32,


  dataloader=dataloader,collate_fn=lambda x:x.to(EXECUTING_DEVICE))


  for op,snr in reports.items():


  if snr>0.1:ppq_warning(f'層{op}的累計量化誤差顯著,請考慮進(jìn)行優(yōu)化')


  if REQUIRE_ANALYSE:


  print('正計算逐層量化誤差(SNR),每一層的獨立量化誤差應(yīng)小于0.1以保證量化精度:')


  layerwise_error_analyse(graph=quantized,running_device=EXECUTING_DEVICE,


  interested_outputs=None,


  dataloader=dataloader,collate_fn=lambda x:x.to(EXECUTING_DEVICE))


  print('網(wǎng)絡(luò)量化結(jié)束,正在生成目標(biāo)文件:')


  export_ppq_graph(


  graph=quantized,platform=TargetPlatform.ONNXRUNTIME,


  graph_save_to=os.path.join(WORKING_DIRECTORY,'quantized.onnx'),


  config_save_to=os.path.join(WORKING_DIRECTORY,'quant_cfg.json'),


  quantized_param=True)#【改】platform:保證輸出onnxruntime格式帶量化和反量化節(jié)點;


  #quantized_param:確保param儲存int8格式,規(guī)避onnxruntime無法量化


合約量化/量化合約/合約跟單/交易所系統(tǒng)開發(fā)實現(xiàn)技術(shù)及源碼詳細(xì)丨成熟穩(wěn)定版的評論 (共 條)

分享到微博請遵守國家法律
毕节市| 泽库县| 黎平县| 济源市| 余姚市| 全州县| 神农架林区| 丹巴县| 兴业县| 邹平县| 文安县| 将乐县| 棋牌| 龙陵县| 咸宁市| 浙江省| 柘城县| 余干县| 晋中市| 大竹县| 定远县| 石泉县| 资中县| 苍山县| 静宁县| 合肥市| 泾川县| 宝鸡市| 绥化市| 深圳市| 呼图壁县| 赫章县| 府谷县| 德化县| 清镇市| 承德市| 德庆县| 朝阳县| 龙游县| 靖远县| 西城区|