Giter Site home page Giter Site logo

whabc100 / my-tfjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iloveyou11/my-tfjs

0.0 1.0 0.0 129 KB

使用tensorflow.js训练AI模型,包括线性回归、逻辑回归、图像识别、语音识别、迁移学习、加载已有模型、模型转化等等

HTML 4.46% JavaScript 95.54%

my-tfjs's Introduction

Tensorflow.js Converter 依赖python3.6.8版本

搭建虚拟环境:

  1. 安装conda 可以使用清华镜像源,安装Miniconda 即可(注意配置环境变量)
  2. 在终端检查conda命令是否可用,并创建指定python版本的虚拟环境 conda create -n [name] python=3.6.8 创建虚拟环境 conda remove -n [name] --all 删除虚拟环境 conda info --envs 查看虚拟环境 conda activate [name] 激活虚拟环境(可以发现python版本已经改变) conda deactivate [name] 退出虚拟环境
  3. 安装tfjs converter pip install tensorflowjs安装 tensorflowjs_converter -h检查是否安装成功

python与JavaScript模型的互转:

  1. 准备工作 conda activate [name]激活 tensorflowjs_converter检查
  2. 开始转换——具体格式建议看文档(github tfjs-converter) 1)python模型转js模型 tensorflowjs_converter --input_format=keras --output_format=tf_layers_model [input_path] [output_path] 2)js模型转python模型 tensorflowjs_converter --input_format=tf_layers_model --output_format=keras [input_path] [output_path]
  3. 验证模型正确性

模型加速:

  1. 分片(--weight_shared_size_bytes=[size]) tensorflowjs_converter --input_format=tf_layers_model --output_format=tf_layers_model --weight_shared_size_bytes=100000 [input_path] [output_path] 在输出文件夹中会发现很多块分片后的模型,这样在加载模型时可以使用并发实现加速
  2. 量化(--quantization_bytes=[n]) tensorflowjs_converter --input_format=tf_layers_model --output_format=tf_layers_model --quantization_bytes=2 [input_path] [output_path]
  3. 通过转为tfjs_graph_model来加速模型——内部实现了凸优化(--output_format=tf_graph_model) tensorflowjs_converter --input_format=tf_layers_model --output_format=tf_graph_model [input_path] [output_path]

拓展学习:

  1. 举一反三,训练不同应用场景的AI模型
  2. 多看官方文档
  3. 使用更多的预训练模型,如目标检测、NLP、人体姿势识别
  4. 做更多智能相关的开源项目或商业项目,增加技术影响力

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.