下面展示一些內聯**片
。
"""
2.神經網路的資料表示
"""# 1.標量(
0d張量)
import numpy as np
x = np.
array(12
)print
(x)print
(x.shape) # 張量的形狀
print
(x.ndim) # 張量的維度=軸,0階
# 2.向量(
1d張量)
x = np.
array([
11,23,
5,9,
17])print
(x)print
(x.shape)
print
(x.ndim) # 1階
# 3.矩陣(
2d張量)
x = np.
array([
[5,3
,1,6
,6],
[3,5
,6,3
,7],
[1,7
,4,6
,3]]
)print
(x)print
(x.shape)
print
(x.ndim) # 2階
# 4.3d張量與更高維張量
x = np.
array([
[[5,
3,1,
6,6]
,[3,
5,6,
3,7]
,[1,
7,4,
6,3]
],[[
5,3,
1,6,
6],[
3,5,
6,3,
7],[
1,7,
4,6,
3]],
[[5,
3,1,
6,6]
,[3,
5,6,
3,7]
,[1,
7,4,
6,3]
]])print
(x)print
(x.shape)
print
(x.ndim) # 3階
# in:
# 5.關鍵屬性
from keras.datasets import mnist # 載入keras中的mnist
資料集(train_images, train_labels)
,(test_images, test_labels)
= mnist.
load_data()
print
(train_images.shape) # 形狀
print
(train_images.ndim) # 軸的個數
print
(train_images.dtype) # 資料型別
# 6.顯示第4個數字
import matplotlib.pyplot as plt
digit = train_images[4]
plt.
imshow
(digit, cmap=plt.cm.binary)
plt.
show()
# 7.
在numpy中操作張量
(張量切片)
my_slice = train_images[10:
100]
print
(my_slice.shape) # 3d(
90,28,
28)
第二週 神經網路基礎
考慮以下兩個隨機數組a和b a np.random.randn 2,3 a.shape 2,3 b np.random.randn 2,1 b.shape 2,1 c a b c的維度是什麼?答 b 列向量 複製3次,以便它可以和a的每一列相加,所以 c.shape 2,3 考慮以下兩個隨機數組a和...
梯度下降 神經網路如何學習?(深度學習第二章)
反覆地將乙個函式的輸入按照負梯度的倍數來輸入的過程被稱為梯度下降,它是讓成本函式向區域性最小值收斂的方法。神經網路學習就是減小成本方程 建議讀michael nielsen關於深度學習和神經網路的數 就是要找到特定的權重偏置,從而使乙個代價函式最小化 計算乙個訓練樣本的價值,需要求出網路的輸出,和期...
曲線 神經網路 神經網路的數學基礎 8(完結)
詳細內容請閱讀 deep learning with python 中文翻譯為 python深度學習 美 弗朗索瓦 肖萊 著 張亮 譯 1 隨機梯度下降 給定乙個可微函式,理論上可以用解析法找到它的最小值 函式的最小值是導數為0 的點,因此你只需找到所有導數為0 的點,然後計算函式在其中哪個點具有最...