2.7 Bitcoin L2
Last updated
Last updated
Bitcoin L2 consists of two components. AIS Chain, which is based on POS (Proof of Stake), and AIW, which is based on POW (Proof of Work).
1οΌAIS Chain: The AIS Chain is responsible for the computational process in the AI algorithm, which trains large and complex data into usable visualized data, with some code structure examples as follows.
def forward(self, name, apis, tokens, desc_good, desc_bad):
code_repr = forward_code(name, apis, tokens)
good_sim = F.cosine_similarity(code_repr, forward_desc(desc_good))
bad_sim = F.cosine_similarity(code_repr, forward_desc(desc_bad))
return (margin - good_sim + bad_sim).clamp(min=1e-6)
python src/3Model/codenn.py --dataset_path data/py/final --model_path data/py/model --batch_size 512 --epoch 800 --gpu
Among them, --dataset_path and --model_path are mandatory parameters, which indicate the directory where the input files are located during training and the directory where the model is saved after training, respectively. There are also some optional parameters, such as.
ο·--batch_size, specify the batch size for training, default 32, here specify 512
ο·--epoch, specify how many epochs to train, default is 200, here is 800
ο·--gpu, specify the GPU to run on, followed by a comma separating the GPU IDs, such as --gpu 0,2, to specify the training on block 0 and block 2 GPUs
ο·--load, if the training is stopped in the middle, you can use this parameter to load the saved model to continue the training.
ο·--save_every_epoch, specifying how many epochs to save the model after.
2οΌAIW Chain: AIW Chain is responsible for the extrapolation process of AI algorithms, which extrapolates the computational results to a reasonable scope and within the scope of human comprehension, and the process of extrapolation also requires a lot of computing power for aggregate analysis.
Implementation principle of the extrapolation algorithm
Extrapolation algorithm code example
episode_rewards = []for episode in range(env.scenario.num_episodes): print(f'=== Episode {episode + 1} ===')
3οΌBitcoin and AIS, AIW cross-chain swap
The cross-chain swap between Bitcoin and AIS, AIW is done by staking after mint, while the swap between AIS and AIW is done by burning after mint.