纸上得来终觉浅,绝知此事要躬行。前面 5 篇文章介绍了机器学习相关的部分基础知识,在本章,笔者将讲解基于 TensorFlow 实现一个简单的线性回归模型,以便增强读者对机器学习的体感。
目录
1.环境准备
在进行机器学习编程练习之前,我们需要准备好环境。在本节,笔者以 MacOS 为例,简单介绍环境准备的相关事项,Windows 也差不多。
1.1 安装 Python3
Mac 操作系统自带 Python,通常是 Python2.7,在终端输入命令:python -V,即可查看 Python 的版本号。虽然 Mac 自带的 Python,但它并不满足机器学的需要,在终端输入命令:python,可以看到如下信息——很显然,我们需要安装 Python3。
$ python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'pyt