机器学习应用区块链系列(一)——如何开发一套自己的智能合约系统

时间:2022-04-25
本文章向大家介绍机器学习应用区块链系列(一)——如何开发一套自己的智能合约系统,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

从今天开始

编辑部将带来机器学习应用区块链系列

由于是第一期,我们想解读一些国外已有的文献和研究。故带来了START-Summit-2017-Blockchain-Machine-Learning-Workshop的演讲稿和示例代码,希望能够给大家带来一些启迪。

介绍

代码的目的是用一个简单的例子来演示如何把区块链技术,智能合约和机器学习结合在一起。 (代码在文末下载)

代码文件

- runTestnet.sh: launches a local development Blockchain for easy testing
- contract.sol: contains the smart contract code in solidity language
- installContract.py: Python script for sending our contract to the Blockchain
- user.py: Python script that contains the actual chat client
- classify.py: Python script to classifiy an image file

流程

推荐使用Linux系统。 安装将集中在Ubuntu Linux 16.04 LTS上,但对于其他发行版应该是类似的。

我们需要先安装Python 2.7,pip,curl和git:

open a Linux Terminal and enter the following command:
sudo apt-get install python2.7 python-pip curl git build-essential libssl-dev

安装当前nodejs版本:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -sudo apt-get install -y nodejs

安装区块链测试环境:

sudo npm install -g ethereumjs-testrpc solc

安装其他Python包:

sudo pip install -U pipsudo pip install -U numpy keras==2.0.0 tensorflow ethjsonrpc h5py Pillow scipy

克隆workshop代码:

cd
git clone https://github.com/thoschm/START-Summit-2017-Blockchain-Machine-Learning-Workshop.git workshop_code

克隆现成的深度学习模型:

cd
git clone https://github.com/fchollet/deep-learning-models.git
cp deep-learning-models/resnet50.py workshop_code/code/
cp deep-learning-models/imagenet_utils.py workshop_code/code/

简单的图像分类示例

cdcd workshop_code/code[get some image file in there]python classify.py image.jpg

当您第一次运行它时,它会从互联网下载预先训练的网络权重。 不需要自己训练。

Using TensorFlow backend.
content:

Downloading data from https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
>  tree_frog  <

PPT展示