dapp/defi智能合約LP流動性質(zhì)押挖礦分紅系統(tǒng)開發(fā)實現(xiàn)技術(shù)分析丨詳細(xì)源碼
區(qū)塊鏈(Blockchain)是指通過去中心化和去信任的方式集體維護(hù)一個可靠數(shù)據(jù)庫的技術(shù)方案。該技術(shù)方案主要讓參與系統(tǒng)中的任意多個節(jié)點,通過一串使用密碼學(xué)方法相關(guān)聯(lián)產(chǎn)生的數(shù)據(jù)塊(block),每個數(shù)據(jù)塊中包含了一定時間內(nèi)的系統(tǒng)全部信息交流數(shù)據(jù),并且生成數(shù)據(jù)指紋用于驗證其信息的有效性和鏈接(chain)下一個數(shù)據(jù)庫塊。
The blockchain+model is a subversion of the Internet plus model.Blockchain will greatly improve the quality,speed,and scale of human socio-economic activities,accelerating the evolution of civilization.If the result of the"Internet plus+traditional industry"model is a monopoly and centralized management industry giant,then the"blockchain+traditional industry"model is to build a new industry ecosystem.Compared with the Internet plus model,the decentralized blockchain+model will greatly improve the quality,speed and scale of human social life and accelerate the evolution of civilization.
從技術(shù)角度分析,開發(fā)技術(shù)詳細(xì)威:yy625019,區(qū)塊鏈讓數(shù)字資產(chǎn)價值流轉(zhuǎn)的每一個節(jié)點都公開透明、有跡可循且不可篡改,這將會讓W(xué)eb3.0時代的一切交易變得更加真實可信。
同時,數(shù)據(jù)通過區(qū)塊鏈技術(shù)可以確定權(quán)屬,實現(xiàn)數(shù)據(jù)的資產(chǎn)化,這也將使得區(qū)塊鏈成為Web3.0時代的基礎(chǔ)設(shè)施。
python wandb_eval.py--use_wandb=0--train_ratio=0.5--test_filename=pykt_test.csv--save_dir="{save_dir}"
def load_model(model_name,model_config,data_config,emb_type,ckpt_path):
model=init_model(model_name,model_config,data_config,emb_type)
net=torch.load(os.path.join(ckpt_path,emb_type+"_model.ckpt"))
model.load_state_dict(net)
return model
testf=os.path.join(data_config["dpath"],params["test_filename"])
其中的get_cur_teststart
大致是從測試集中找到其中的訓(xùn)練部分和預(yù)測部分,repeat部分也都去掉了
然后
dtotal={“cq”:cq,“cc”:cc,“cr”:cr,“ct”:ct}是全部長度
cur前綴的則只包括已知的部分:curcin,currin,curqin
先來看累計預(yù)測的predict_each_group
從預(yù)測部分的index開始循環(huán).
如果前綴部分超過Max_len,則都取后半部分
dkt:
y=model(cin.long(),rin.long())
#print(y)
pred=y[0][-1][cout.item()]
同時,通過t進(jìn)行迭代。為啥有兩層循環(huán)呢?原文這里寫的有點晦澀難懂了。
第二層循環(huán)很短,t~end
循環(huán)主要是預(yù)測的response會作為下一個的輸入
def get_cur_teststart(is_repeat,train_ratio):
curl=len(is_repeat)
#print(is_repeat)
qlen=is_repeat.count(0)#其中不重復(fù)的長度
qtrainlen=int(qlen*train_ratio)#已知的長度
qtrainlen=1 if qtrainlen==0 else qtrainlen#保證已知長度至少大于0,否則輸入為空
qtrainlen=qtrainlen-1 if qtrainlen==qlen else qtrainlen#保證測試長度大于0,否則測試輸入為空
#get real concept len
ctrainlen,qidx=0,0
i=0
while i<curl:
if is_repeat<i>==0:
qidx+=1#qidx是不重復(fù)的長度
#print(f"i:{i},curl:{curl},qidx:{qidx},qtrainlen:{qtrainlen}")
#qtrainlen=7 if qlen>7 else qtrainlen
if qidx==qtrainlen:#如果已經(jīng)到了設(shè)定的已知,那么退出
break
i+=1
for j in range(i+1,curl):
if is_repeat[j]==0:
ctrainlen=j#找到response未知的部分,第一個不重復(fù)的作為預(yù)測起點?
break
return qlen,qtrainlen,ctrainlen