機器學習入門 - Google的機器學習速成課程

1 - MLCC

經過機器學習,能夠有效地解讀數據的潛在含義,甚至能夠改變思考問題的方式,使用統計信息而非邏輯推理來處理問題。 Google的機器學習速成課程(MLCC,machine-learning crash-course):https://developers.google.com/machine-learning/crash-course/ 支持多語言,共25節課程,包含40多項練習,有對算法實際運用的互動直觀展現,能夠更容易地學習和實踐機器學習概念。 官方預估時間大約15小時(實際花費時間根據我的狀況而定,差別較大)。php

注意:這裏的時間長度指的是教程播放和閱讀的時間,而不是你「真正」理解吸取和練習的時間。 實際上,對於「小白」階段的新手,可能要投入數倍於此的精力,才能完成整個學習過程(觀看、閱讀、理解、練習、瞭解相關知識點、等等)。html

本課程將解答以下問題:python

  • 機器學習與傳統編程有何不一樣?
  • 什麼是損失,如何衡量損失?
  • 梯度降低法的運做方式是怎樣的?
  • 如何肯定個人模型是否有效?
  • 怎樣爲機器學習提供個人數據?
  • 如何構建深度神經網絡?

機器學習術語表git

1.1 - 練習環境:本地運行

MLCC相關練習:https://developers.google.com/machine-learning/crash-course/exercisesgithub

涉及的命令web

(base) >conda create -n mlcc pip python=3.6
(base) >conda activate mlcc
(mlcc) >pip --proxy="10.144.1.10:8080" install --ignore-installed --upgrade tensorflow matplotlib pandas sklearn scipy seaborn  # pip使用代理
(mlcc) >pip install --ignore-installed --upgrade tensorflow matplotlib pandas sklearn scipy seaborn -i https://mirrors.ustc.edu.cn/pypi/web/simple/  # pip使用國內源

示例算法

(base) C:\Users\guowli>conda create -n mlcc pip python=3.6
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Office-Tools\Anaconda3\envs\mlcc

  added / updated specs:
    - pip
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2019.3.9           |           py36_0         156 KB  defaults
    pip-19.1.1                 |           py36_0         1.9 MB  defaults
    python-3.6.8               |       h9f7ef89_7        20.3 MB  defaults
    setuptools-41.0.1          |           py36_0         663 KB  defaults
    sqlite-3.28.0              |       he774522_0         945 KB  defaults
    vs2015_runtime-14.15.26706 |       h3a45250_4         2.4 MB  defaults
    wheel-0.33.2               |           py36_0          57 KB  defaults
    wincertstore-0.2           |   py36h7fe50ca_0          13 KB  defaults
    ------------------------------------------------------------
                                           Total:        26.4 MB

The following NEW packages will be INSTALLED:

  certifi            pkgs/main/win-64::certifi-2019.3.9-py36_0
  pip                pkgs/main/win-64::pip-19.1.1-py36_0
  python             pkgs/main/win-64::python-3.6.8-h9f7ef89_7
  setuptools         pkgs/main/win-64::setuptools-41.0.1-py36_0
  sqlite             pkgs/main/win-64::sqlite-3.28.0-he774522_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.15.26706-h3a45250_4
  wheel              pkgs/main/win-64::wheel-0.33.2-py36_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py36h7fe50ca_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
setuptools-41.0.1    | 663 KB    | ######################################################################### | 100%
certifi-2019.3.9     | 156 KB    | ######################################################################### | 100%
wincertstore-0.2     | 13 KB     | ######################################################################### | 100%
pip-19.1.1           | 1.9 MB    | ######################################################################### | 100%
vs2015_runtime-14.15 | 2.4 MB    | ######################################################################### | 100%
wheel-0.33.2         | 57 KB     | ######################################################################### | 100%
python-3.6.8         | 20.3 MB   | ######################################################################### | 100%
sqlite-3.28.0        | 945 KB    | ######################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate mlcc
#
# To deactivate an active environment, use
#
#     $ conda deactivate


(base) C:\Users\guowli>conda env list
# conda environments:
#
base                  *  C:\Office-Tools\Anaconda3
mlcc                     C:\Office-Tools\Anaconda3\envs\mlcc


(base) C:\Users\guowli>conda activate mlcc

(mlcc) C:\Users\guowli>pip list
Package      Version
------------ --------
certifi      2019.3.9
pip          19.1.1
setuptools   41.0.1
wheel        0.33.2
wincertstore 0.2

(mlcc) C:\Users\guowli>pip --proxy="10.144.1.10:8080" install --ignore-installed --upgrade tensorflow matplotlib pandas sklearn scipy seaborn
Collecting tensorflow
  Downloading https://files.pythonhosted.org/packages/bf/58/34bfa8fa17f86333361172b3b502e805195180f19a7496ad0f6149138d55/tensorflow-1.13.1-cp36-cp36m-win_amd64.whl (63.1MB)
     |████████████████████████████████| 63.1MB 598kB/s
Collecting matplotlib
  Downloading https://files.pythonhosted.org/packages/21/4c/35fa1837a705f33621604a1967b1505bd3f695940fdf02fad77ef11de196/matplotlib-3.0.3-cp36-cp36m-win_amd64.whl (9.1MB)
     |████████████████████████████████| 9.1MB 544kB/s
......
......
......
Collecting joblib>=0.11 (from scikit-learn->sklearn)
  Downloading https://files.pythonhosted.org/packages/cd/c1/50a758e8247561e58cb87305b1e90b171b8c767b15b12a1734001f41d356/joblib-0.13.2-py2.py3-none-any.whl (278kB)
     |████████████████████████████████| 286kB 6.4MB/s
Building wheels for collected packages: sklearn, absl-py, gast, termcolor
  Building wheel for sklearn (setup.py) ... done
  Stored in directory: C:\Users\guowli\AppData\Local\pip\Cache\wheels\76\03\bb\589d421d27431bcd2c6da284d5f2286c8e3b2ea3cf1594c074
  Building wheel for absl-py (setup.py) ... done
  Stored in directory: C:\Users\guowli\AppData\Local\pip\Cache\wheels\ee\98\38\46cbcc5a93cfea5492d19c38562691ddb23b940176c14f7b48
  Building wheel for gast (setup.py) ... done
  Stored in directory: C:\Users\guowli\AppData\Local\pip\Cache\wheels\5c\2e\7e\a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd
  Building wheel for termcolor (setup.py) ... done
  Stored in directory: C:\Users\guowli\AppData\Local\pip\Cache\wheels\7c\06\54\bc84598ba1daf8f970247f550b175aaaee85f68b4b0c5ab2c6
Successfully built sklearn absl-py gast termcolor
Installing collected packages: six, setuptools, protobuf, numpy, absl-py, markdown, werkzeug, wheel, grpcio, tensorboard, astor, keras-preprocessing, gast, mock, tensorflow-estimator, termcolor, h5py, keras-applications, tensorflow, kiwisolver, pyparsing, python-dateutil, cycler, matplotlib, pytz, pandas, scipy, joblib, scikit-learn, sklearn, seaborn
Successfully installed absl-py-0.7.1 astor-0.7.1 cycler-0.10.0 gast-0.2.2 grpcio-1.20.1 h5py-2.9.0 joblib-0.13.2 keras-applications-1.0.7 keras-preprocessing-1.0.9 kiwisolver-1.1.0 markdown-3.1 matplotlib-3.0.3 mock-3.0.5 numpy-1.16.3 pandas-0.24.2 protobuf-3.7.1 pyparsing-2.4.0 python-dateutil-2.8.0 pytz-2019.1 scikit-learn-0.21.0 scipy-1.2.1 seaborn-0.9.0 setuptools-41.0.1 six-1.12.0 sklearn-0.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.15.2 wheel-0.33.4

(mlcc) C:\Users\guowli>
(mlcc) C:\Users\guowli>pip list
Package              Version
-------------------- --------
absl-py              0.7.1
astor                0.7.1
certifi              2019.3.9
cycler               0.10.0
gast                 0.2.2
grpcio               1.20.1
h5py                 2.9.0
joblib               0.13.2
Keras-Applications   1.0.7
Keras-Preprocessing  1.0.9
kiwisolver           1.1.0
Markdown             3.1
matplotlib           3.0.3
mock                 3.0.5
numpy                1.16.3
pandas               0.24.2
pip                  19.1.1
protobuf             3.7.1
pyparsing            2.4.0
python-dateutil      2.8.0
pytz                 2019.1
scikit-learn         0.21.0
scipy                1.2.1
seaborn              0.9.0
setuptools           41.0.1
six                  1.12.0
sklearn              0.0
tensorboard          1.13.1
tensorflow           1.13.1
tensorflow-estimator 1.13.0
termcolor            1.1.0
Werkzeug             0.15.2
wheel                0.33.4
wincertstore         0.2

(mlcc) C:\Users\guowli>

1.2 - 練習環境:在線運行

1.3 - 前提條件和準備工做

MLCC Prereqs and prework:https://developers.google.com/machine-learning/crash-course/prereqs-and-preworksql

前提條件

掌握入門級代數知識。 
    瞭解變量和係數、線性方程式、函數圖和直方圖(熟悉對數和導數等更高級的數學概念會有幫助,但不是必需條件)。

熟練掌握編程基礎知識,而且具備一些使用 Python 進行編碼的經驗。
    機器學習速成課程中的編程練習是經過TensorFlow並使用Python進行編碼的。
    無需擁有任何 TensorFlow經驗,但應該可以熟練閱讀和編寫包含基礎編程結構(例如,函數定義/調用、列表和字典、循環和條件表達式)的Python代碼。

準備工做

Pandas 使用入門
    機器學習速成課程中的編程練習使用 Pandas 庫來操控數據集。
    若是不熟悉 Pandas,建議先學習Pandas 簡介教程,該教程介紹了練習中使用的主要 Pandas 功能。

低階 TensorFlow 基礎知識
   機器學習速成課程中的編程練習使用 TensorFlow 的高階 tf.estimator API 來配置模型。
   若是有興趣從頭開始構建 TensorFlow 模型,請學習如下教程:
     - TensorFlow Hello World:在低階 TensorFlow 中編碼的「Hello World」。
     - TensorFlow 編程概念:演示了 TensorFlow 應用中的基本組件:張量、指令、圖和會話。
     - 建立和操控張量:張量快速入門 - TensorFlow 編程中的核心概念。此外,還回顧了線性代數中的矩陣加法和乘法概念。

1.4 - 主要概念和工具

數學

代數
    - 變量、係數和函數
    - 線性方程式
    - 對數和對數方程式
    - S型函數

線性代數
    - 張量和張量等級
    - 矩陣乘法

三角學
    - Tanh(做爲激活函數進行講解,無需提早掌握相關知識)

統計信息
    - 均值、中間值、離羣值和標準誤差
    - 可以讀懂直方圖

微積分(可選,適合高級主題)
    - 導數概念(您沒必要真正計算導數)
    - 梯度或斜率
    - 偏導數(與梯度緊密相關)
    - 鏈式法則(帶您全面瞭解用於訓練神經網絡的反向傳播算法)

Python(https://docs.python.org/3/tutorial/)

基礎 Python
    - 定義和調用函數:使用位置和關鍵字參數
    - 字典、列表、集合(建立、訪問和迭代)
    - for 循環:包含多個迭代器變量的 for 循環(例如 for a, b in [(1,2), (3,4)])
    - if/else 條件塊和條件表達式
    - 字符串格式(例如 '%.2f' % 3.14)
    - 變量、賦值、基本數據類型(int、float、bool、str)
    - pass 語句
中級 Python
    - 列表推導式
    - Lambda 函數

第三方Python庫(無需提早熟悉,在須要時查詢相關內容)

Matplotlib(適合數據可視化)
    - pyplot 模塊
    - cm 模塊
    - gridspec 模塊

Seaborn(適合熱圖)
    - heatmap 函數

Pandas(適合數據處理)
    - DataFrame 類

NumPy(適合低階數學運算)
    - linspace 函數
    - random 函數
    - array 函數
    - arange 函數

Scikit-Learn(適合評估指標)
   - metrics 模塊

Bash

2 - 下一步

2.1 - Google的機器學習指南

https://developers.google.com/machine-learning/guides/ 經過簡單的逐步演示介紹如何利用最佳作法解決常見的機器學習問題。shell

2.2 - Machine Learning Practica

Google的機器學習實踐:https://developers.google.com/machine-learning/practica/編程

2.3 - 深刻了解官網文檔

以TensorFlow爲例:

相關文章
相關標籤/搜索