Jammy@Jetson Orin - Tensorflow Keras Get Started: 000 setup for tutorial

2024-04-30 04:12

本文主要是介绍Jammy@Jetson Orin - Tensorflow Keras Get Started: 000 setup for tutorial,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Jammy@Jetson Orin - Tensorflow & Keras Get Started: 000 setup for tutorial

  • 1. 源由
  • 2. 搭建环境
    • 2.1 安装IDE环境
    • 2.2 安装numpy
    • 2.3 安装keras
    • 2.4 安装JAX
    • 2.5 安装tensorflow
    • 2.6 安装PyTorch
    • 2.7 安装nbdiff
  • 3. 测试DEMO
    • 3.1 numpy版本兼容问题
    • 3.2 karas API - model.compile问题
    • 3.3 karas API - model.predict问题
  • 4. 总结
  • 5. 参考资料

1. 源由

凡事开头难!入门搭建环境难!

这里就从最基本的环境搭建和大家共一起勉!

2. 搭建环境

2.1 安装IDE环境

  • jupyterlab环境
$ pip install jupyterlab
$ jupyter lab
  • jupyternotebook环境
$ pip install notebook
$ jupyter notebook

注:推荐使用jupyterlab。

2.2 安装numpy

$ pip install -U numpy  //升级到最新版本$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.26.4'
>>>

注:升级到指定版本可以使用命令pip install numpy==1.24.3

2.3 安装keras

$ pip install --upgrade keras$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
>>> keras.__version__
'3.3.2'
>>>

参考:Keras Get Started

2.4 安装JAX

  • CPU-only (Linux/macOS/Windows)
$ pip install -U "jax[cpu]"
  • GPU (NVIDIA, CUDA 12, x86_64)
$ pip install -U "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

注:更多关于JAX的硬件版本信息,详见:Installing JAX

2.5 安装tensorflow

$ pip install tensorflow$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.16.1'
>>> tf.__path__
['/home/daniel/.local/lib/python3.10/site-packages/keras/api/_v2', '/home/daniel/.local/lib/python3.10/site-packages/keras/_tf_keras', '/home/daniel/.local/lib/python3.10/site-packages/tensorflow', '/home/daniel/.local/lib/python3.10/site-packages/tensorflow/_api/v2']
>>>

注意:目前tensorflow的安装存在一些GPU版本的问题,参考下面的链接资料。

  • How to install tensorflow with GPU support on Jetson Orin Nano?
  • Tensorflow v2.16.1 GPU version local build on Jetson Orin Nano failed

2.6 安装PyTorch

具体安装版本因硬件差异,命令不同,详见:Install pytorch

在这里插入图片描述因为,笔者这里环境是Jetson Orin,所以选择了上面的配置版本:

$ pip install torch torchvision torchaudio

2.7 安装nbdiff

鉴于.ipynb文件会包含最后一次执行的输出信息,不像通常代码diff那样可以看的很清楚,这里需要安装一个类似diff的命令。

$ pip install nbdime$ nbdiff --help
usage: nbdiff [-h] [--version] [--config] [--log-level {DEBUG,INFO,WARN,ERROR,CRITICAL}] [-s] [-o] [-a] [-m] [-i] [-d] [--color-words] [--no-color] [--no-git] [--no-use-diff] [--out OUT][base] [remote] [paths ...]Compute the difference between two Jupyter notebooks.positional arguments:base                  the base notebook filename OR base git-revision.remote                the remote modified notebook filename OR remote git-revision.paths                 filter diffs for git-revisions based on pathoptions:-h, --help            show this help message and exit--version             show program's version number and exit--config              list the valid config keys and their current effective values--log-level {DEBUG,INFO,WARN,ERROR,CRITICAL}set the log level by name.--color-words         whether to pass the --color-words flag to any internal calls to git diff--no-color            prevent use of ANSI color code escapes for text output--no-git              prevent use of git for formatting diff/merge text output--no-use-diff         prevent use of diff/diff3 for formatting diff/merge text output--out OUT             if supplied, the diff is written to this file. Otherwise it is printed to the terminal.ignorables:Set which parts of the notebook (not) to process.-s, --sources, -S, --ignore-sourcesprocess/ignore sources.-o, --outputs, -O, --ignore-outputsprocess/ignore outputs.-a, --attachments, -A, --ignore-attachmentsprocess/ignore attachments.-m, --metadata, -M, --ignore-metadataprocess/ignore metadata.-i, --id, -I, --ignore-idprocess/ignore identifiers.-d, --details, -D, --ignore-detailsprocess/ignore details not covered by other options.

3. 测试DEMO

学习是一个过程,是一种大学生应该掌握的技能。手把手教那是在学校,真正的学习是不断的自我学习和提高,这种螺旋式学习技能将会受益一辈子!

即使很好的搭建了环境,代码依然会出现问题!

001_Keras-Linear-Regression

$ git log -n 2
commit 84b7f5ee7c80d9faecf79af96f8a677f47c44f0d (HEAD -> main, origin/main, origin/HEAD)
Author: Daniel Li <lida_mail@163.com>
Date:   Tue Apr 23 16:49:42 2024 +0800Fix Keras-Linear-Regression demo code issue with Jammy(Jetson Orin)commit 8c89b4c2b9e9df2e854f280ce19ed3010c7ac2fc
Author: Daniel Li <lida_mail@163.com>
Date:   Tue Apr 23 15:00:46 2024 +0800Add raw 001_Keras-Linear-Regression/Keras-Linear-Regression.ipynb

3.1 numpy版本兼容问题

在这里插入图片描述
解决方法:numpy版本降级

$ pip install numpy==1.23.4

3.2 karas API - model.compile问题

在这里插入图片描述

解决方法:修正API入参参数

## modified /cells/15/source:
@@ -1,2 +1,2 @@
-model.compile(optimizer=tf.keras.optimizers.RMSprop(lr=.005),
+model.compile(optimizer=tf.keras.optimizers.RMSprop(learning_rate=.005),loss='mse')

3.3 karas API - model.predict问题

在这里插入图片描述
解决方法:修正API入参参数

## modified /cells/23/source:
@@ -1,5 +1,5 @@# Predict the median price of a home with [3, 4, 5, 6, 7] rooms.
-x = [3, 4, 5, 6, 7]
-y_pred = model.predict(x)
-for idx in range(len(x)):
-    print("Predicted price of a home with {} rooms: ${}K".format(x[idx], int(y_pred[idx]*10)/10))+rooms = [3, 4, 5, 6, 7]
+y_pred = model.predict(x = np.array(rooms))
+for idx in range(len(rooms)):
+    print("Predicted price of a home with {} rooms: ${}K".format(rooms[idx], int(y_pred[idx][0]*10)/10))

4. 总结

学习的第一步,总是感觉那么繁琐,如果感兴趣可以直接写一个setup.sh脚本。

但从学习的角度,一个问题,一个脚印,一步步的操作,纠错,理解,为后续组件/系统的理解可以奠定非常好的基础。

万事开头难,其实就是这么简单的一回事情!

关于线性拟合,这个大家估计能看到这里的兄弟们,都懂的。后面我们也会专门看下科学计算方法和这个神经网络拟合之间的差异。

切记一点,神经网络这个是模拟人类大脑的的工作模式,尽管对于人类大脑工作原理远没有搞得这么清楚,但是从目前的一些视频/图片识别角度看,该方法确实比较好的解决了多因素预测的准确性问题(大概率的准确性)。

相信数学原理更深层次的论证有待去研究渐近和收敛的问题,或者说需要更好的专业领域知识叠加神经网络算法来做到更好的应用。

5. 参考资料

【1】Jammy@Jetson Orin - Tensorflow & Keras Get Started

这篇关于Jammy@Jetson Orin - Tensorflow Keras Get Started: 000 setup for tutorial的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/947876

相关文章

基于CTPN(tensorflow)+CRNN(pytorch)+CTC的不定长文本检测和识别

转发来源:https://swift.ctolib.com/ooooverflow-chinese-ocr.html chinese-ocr 基于CTPN(tensorflow)+CRNN(pytorch)+CTC的不定长文本检测和识别 环境部署 sh setup.sh 使用环境: python 3.6 + tensorflow 1.10 +pytorch 0.4.1 注:CPU环境

BD错误集锦3——ERROR: Can't get master address from ZooKeeper; znode data == null

hbase集群没启动,傻子!   启动集群 [s233 s234 s235]启动zk集群 $>zkServer.sh start $>zkServer.sh status   [s233] 启动dfs系统 $>start-dfs.sh 如果s237 namenode启动失败,则 [s237] $>hadoop-daemon.sh start namenode [s233]启动yarn集群

[分布式网络通讯框架]----Zookeeper客户端基本操作----ls、get、create、set、delete

Zookeeper数据结构 zk客户端常用命令 进入客户端 在bin目录下输入./zkCli.sh 查看根目录下数据ls / 注意:要查看哪一个节点,必须把路径写全 查看节点数据信息 get /第一行代码数据,没有的话表示没有数据 创建节点create /sl 20 /sl为节点的路径,20为节点的数据 注意,不能跨越创建,也就是说,创建sl2的时候,必须确保sl

【图像识别系统】昆虫识别Python+卷积神经网络算法+人工智能+深度学习+机器学习+TensorFlow+ResNet50

一、介绍 昆虫识别系统,使用Python作为主要开发语言。通过TensorFlow搭建ResNet50卷积神经网络算法(CNN)模型。通过对10种常见的昆虫图片数据集(‘蜜蜂’, ‘甲虫’, ‘蝴蝶’, ‘蝉’, ‘蜻蜓’, ‘蚱蜢’, ‘蛾’, ‘蝎子’, ‘蜗牛’, ‘蜘蛛’)进行训练,得到一个识别精度较高的H5格式模型文件,然后使用Django搭建Web网页端可视化操作界面,实现用户上传一

【鸿蒙】ERROR_GET_BUNDLE_INSTALLER_FAILED

错误信息 [ERROR_GET_BUNDLE_INSTALLER_FAILED] Troubleshooting guide $ hdc file send D:\Huawei\devEcoProjects\entry\build\default\outputs\default\entry-default-unsigned.hap /sdcard/e8a215ea7be1444197e6a58e

关于IE get 请求报400

问题描述: 在使用IE8进行get请求时,参数中有中文存在,发现发送请求之后,返回http状态码400 问题解决方法: 把请求连接进行处理window.encodeURI('http://aaa:8080/wtp?name=小明'); window.location.href=window.encodeURI('http://aaa:8080/wtp?name=小明'); 然后在把处理后

JetSon Tx1 串口使用记录

最近在学习使用Jetson Tx1,下面是使用串口遇到的问题,做为我的第一篇博客。 Jetson Tx1串口是TTL电平。 Jetson Tx1的UART0在Linux上的设备号是“/dev/tty0”,但是在Tx1刷的系统中,UART0默认是做为console serail设备使用的,这个具体有什么作用,我也不大清楚了,百度一下也不是很懂。这就导致了在Linux上使用串口调试工具和PC机相连

Creating custom and compound Views in Android - Tutorial(翻译)

Creating custom and compound Views in Android - Tutorial(翻译) 译前的: 之前做了三篇学习笔记,从知乎上面看到了这篇英文的推荐,总的来说可以是一篇导读,没有相关的学习,看这篇,可以作为一个学习脉络导向;有相关的学习底子,可以作为一个基础夯实、思维理清。没想到一翻译就是四个多小时…英语渣,很多词句都不太准确,幸好有之前的学习基础打底…

面试题3:GET 和 POST 有什么区别?

[!]高频面试题。 GET 和 POST 没有本质区别,可以进行相互代替。 1、GET语义:“从服务器获取数据”;POST语义:“往服务器上提交数据”。[设计初衷,不一定要遵守] 2、发请求时,给服务器传递的数据,GET 一般是放在查询字符串中,但GET 也可以把数据放在 body 里。不过比较少见,以至于浏览器不一定能支持,不过其他的http客户端可以支持;POST 一般是放在 body 中

ansible setup模块

用于收集有关目标主机的系统和网络信息,并将这些信息存储为一个facts变量,可以在Playbook的后续任务中使用。setup模块可以用来获取主机的操作系统、软件包、IP地址、内存、磁盘和其他硬件信息。这些信息对编写Playbook和进行条件判断非常有用。当你在Playbook或者直接通过Ansible命令行使用setup模块时,它会返回一个包含目标主机详细信息的JSON结构,这些信息包括但不限于