首页 > 其他分享 >深度学习 - RNN训练过程推演

深度学习 - RNN训练过程推演

时间:2024-06-15 20:03:33浏览次数:12  
标签:loss partial RNN tanh text 推演 pmatrix 深度 frac

1. 数据准备

字符序列 “hello” 转换为 one-hot 编码表示:

  • 输入: [‘h’, ‘e’, ‘l’, ‘l’]
  • 输出: [‘e’, ‘l’, ‘l’, ‘o’]

2. 初始化参数

假设我们使用一个单层的 RNN,隐藏层大小为2。初始参数如下:

W x h = ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ) , W h h = ( 0.1 0.2 0.3 0.4 ) , W h y = ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ) W_{xh} = \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \\ 0.5 & 0.6 \\ 0.7 & 0.8 \end{pmatrix}, \quad W_{hh} = \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \end{pmatrix}, \quad W_{hy} = \begin{pmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.5 & 0.6 & 0.7 & 0.8 \end{pmatrix} Wxh​= ​0.10.30.50.7​0.20.40.60.8​ ​,Whh​=(0.10.3​0.20.4​),Why​=(0.10.5​0.20.6​0.30.7​0.40.8​)

偏置项初始化为0。

3. 前向传播和反向传播

时间步 1(输入 ‘h’):

输入向量 x 1 = [ 1 , 0 , 0 , 0 ] x_1 = [1, 0, 0, 0] x1​=[1,0,0,0]

h 1 = tanh ⁡ ( W x h x 1 + W h h h 0 ) = tanh ⁡ ( ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ) ( 1 0 0 0 ) + ( 0.1 0.2 0.3 0.4 ) ( 0 0 ) ) = tanh ⁡ ( ( 0.1 0.3 ) ) = ( 0.0997 0.2913 ) h_1 = \tanh(W_{xh} x_1 + W_{hh} h_0) = \tanh \left( \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \\ 0.5 & 0.6 \\ 0.7 & 0.8 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} + \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \end{pmatrix} \begin{pmatrix} 0 \\ 0 \end{pmatrix} \right) = \tanh \left( \begin{pmatrix} 0.1 \\ 0.3 \end{pmatrix} \right) = \begin{pmatrix} 0.0997 \\ 0.2913 \end{pmatrix} h1​=tanh(Wxh​x1​+Whh​h0​)=tanh ​0.10.30.50.7​0.20.40.60.8​ ​1000​ ​+(0.10.3​0.20.4​)(00​) ​=tanh((0.10.3​))=(0.09970.2913​)

y 1 = W h y h 1 = ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ) ( 0.0997 0.2913 ) = ( 0.1695 0.3889 0.6083 0.8277 ) y_1 = W_{hy} h_1 = \begin{pmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.5 & 0.6 & 0.7 & 0.8 \end{pmatrix} \begin{pmatrix} 0.0997 \\ 0.2913 \end{pmatrix} = \begin{pmatrix} 0.1695 \\ 0.3889 \\ 0.6083 \\ 0.8277 \end{pmatrix} y1​=Why​h1​=(0.10.5​0.20.6​0.30.7​0.40.8​)(0.09970.2913​)= ​0.16950.38890.60830.8277​

预测值 y ^ 1 = softmax ( y 1 ) \hat{y}_1 = \text{softmax}(y_1) y^​1​=softmax(y1​)

假设真实输出为 ‘e’,对应 one-hot 编码为 y 1 = [ 0 , 1 , 0 , 0 ] y_1 = [0, 1, 0, 0] y1​=[0,1,0,0]。

交叉熵损失函数:

loss 1 = − ∑ i y 1 i log ⁡ ( y ^ 1 i ) \text{loss}_1 = - \sum_{i} y_{1i} \log(\hat{y}_{1i}) loss1​=−i∑​y1i​log(y^​1i​)

梯度计算:

∂ loss 1 ∂ W h y = ( y ^ 1 − y 1 ) h 1 T \frac{\partial \text{loss}_1}{\partial W_{hy}} = (\hat{y}_1 - y_1) h_1^T ∂Why​∂loss1​​=(y^​1​−y1​)h1T​

∂ loss 1 ∂ W x h = ∂ loss 1 ∂ h 1 ⋅ ∂ h 1 ∂ W x h \frac{\partial \text{loss}_1}{\partial W_{xh}} = \frac{\partial \text{loss}_1}{\partial h_1} \cdot \frac{\partial h_1}{\partial W_{xh}} ∂Wxh​∂loss1​​=∂h1​∂loss1​​⋅∂Wxh​∂h1​​

∂ loss 1 ∂ W h h = ∂ loss 1 ∂ h 1 ⋅ ∂ h 1 ∂ W h h \frac{\partial \text{loss}_1}{\partial W_{hh}} = \frac{\partial \text{loss}_1}{\partial h_1} \cdot \frac{\partial h_1}{\partial W_{hh}} ∂Whh​∂loss1​​=∂h1​∂loss1​​⋅∂Whh​∂h1​​

参数更新:

W x h = W x h − η ∂ loss 1 ∂ W x h W_{xh} = W_{xh} - \eta \frac{\partial \text{loss}_1}{\partial W_{xh}} Wxh​=Wxh​−η∂Wxh​∂loss1​​

W h h = W h h − η ∂ loss 1 ∂ W h h W_{hh} = W_{hh} - \eta \frac{\partial \text{loss}_1}{\partial W_{hh}} Whh​=Whh​−η∂Whh​∂loss1​​

W h y = W h y − η ∂ loss 1 ∂ W h y W_{hy} = W_{hy} - \eta \frac{\partial \text{loss}_1}{\partial W_{hy}} Why​=Why​−η∂Why​∂loss1​​

时间步 2(输入 ‘e’):

使用更新后的 W x h W_{xh} Wxh​、 W h h W_{hh} Whh​ 和 W h y W_{hy} Why​ 参数。

输入向量 x 2 = [ 0 , 1 , 0 , 0 ] x_2 = [0, 1, 0, 0] x2​=[0,1,0,0]

h 2 = tanh ⁡ ( W x h x 2 + W h h h 1 ) = tanh ⁡ ( ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ) ( 0 1 0 0 ) + ( 0.1 0.2 0.3 0.4 ) ( 0.0997 0.2913 ) ) h_2 = \tanh(W_{xh} x_2 + W_{hh} h_1) = \tanh \left( \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \\ 0.5 & 0.6 \\ 0.7 & 0.8 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} + \begin{pmatrix} 0.1 & 0.2 \\ 0.3 & 0.4 \end{pmatrix} \begin{pmatrix} 0.0997 \\ 0.2913 \end{pmatrix} \right) h2​=tanh(Wxh​x2​+Whh​h1​)=tanh ​0.10.30.50.7​0.20.40.60.8​ ​0100​ ​+(0.10.3​0.20.4​)(0.09970.2913​)

计算后得:

h 2 = tanh ⁡ ( ( 0.3 0.7 ) + ( 0.1283 0.2147 ) ) = tanh ⁡ ( ( 0.4283 0.9147 ) ) h_2 = \tanh \left( \begin{pmatrix} 0.3 \\ 0.7 \end{pmatrix} + \begin{pmatrix} 0.1283 \\ 0.2147 \end{pmatrix} \right) = \tanh \left( \begin{pmatrix} 0.4283 \\ 0.9147 \end{pmatrix} \right) h2​=tanh((0.30.7​)+(0.12830.2147​))=tanh((0.42830.9147​))

y 2 = W h y h 2 y_2 = W_{hy} h_2 y2​=Why​h2​

预测值 y ^ 2 = softmax ( y 2 ) \hat{y}_2 = \text{softmax}(y_2) y^​2​=softmax(y2​)

假设真实输出为 ‘l’,对应 one-hot 编码为 y 2 = [ 0 , 0 , 1 , 0 ] y_2 = [0, 0, 1, 0] y2​=[0,0,1,0]。

交叉熵损失函数:

loss 2 = − ∑ i y 2 i log ⁡ ( y ^ 2 i ) \text{loss}_2 = - \sum_{i} y_{2i} \log(\hat{y}_{2i}) loss2​=−i∑​y2i​log(y^​2i​)

梯度计算:

∂ loss 2 ∂ W h y = ( y ^ 2 − y 2 ) h 2 T \frac{\partial \text{loss}_2}{\partial W_{hy}} = (\hat{y}_2 - y_2) h_2^T ∂Why​∂loss2​​=(y^​2​−y2​)h2T​

∂ loss 2 ∂ W x h = ∂ loss 2 ∂ h 2 ⋅ ∂ h 2 ∂ W x h \frac{\partial \text{loss}_2}{\partial W_{xh}} = \frac{\partial \text{loss}_2}{\partial h_2} \cdot \frac{\partial h_2}{\partial W_{xh}} ∂Wxh​∂loss2​​=∂h2​∂loss2​​⋅∂Wxh​∂h2​​

∂ loss 2 ∂ W h h = ∂ loss 2 ∂ h 2 ⋅ ∂ h 2 ∂ W h h \frac{\partial \text{loss}_2}{\partial W_{hh}} = \frac{\partial \text{loss}_2}{\partial h_2} \cdot \frac{\partial h_2}{\partial W_{hh}} ∂Whh​∂loss2​​=∂h2​∂loss2​​⋅∂Whh​∂h2​​

参数更新:

W x h = W x h − η ∂ loss 2 ∂ W x h W_{xh} = W_{xh} - \eta \frac{\partial \text{loss}_2}{\partial W_{xh}} Wxh​=Wxh​−η∂Wxh​∂loss2​​

W h h = W h h − η ∂ loss 2 ∂ W h h W_{hh} = W_{hh} - \eta \frac{\partial \text{loss}_2}{\partial W_{hh}} Whh​=Whh​−η∂Whh​∂loss2​​

W h y = W h y − η ∂ loss 2 ∂ W h y W_{hy} = W_{hy} - \eta \frac{\partial \text{loss}_2}{\partial W_{hy}} Why​=Why​−η∂Why​∂loss2​​

时间步 3(输入 ‘l’):

使用更新后的 W x h W_{xh} Wxh​、 W h h W_{hh} Whh​ 和 W h y W_{hy} Why​ 参数。

输入向量 x 3 = [ 0 , 0 , 1 , 0 ] x_3 = [0, 0, 1, 0] x3​=[0,0,1,0]

h 3 = tanh ⁡ ( W x h x 3 + W h h h 2 ) h_3 = \tanh(W_{xh} x_3 + W_{hh} h_2) h3​=tanh(Wxh​x3​+Whh​h2​)

计算后得:

h 3 = tanh ⁡ ( ( 0.5 1.2 ) + W h h h 2 ) h_3 = \tanh \left( \begin{pmatrix} 0.5 \\ 1.2 \end{pmatrix} + W_{hh} h_2 \right) h3​=tanh((0.51.2​)+Whh​h2​)

y 3 = W h y h 3 y_3 = W_{hy} h_3 y3​=Why​h3​

预测值 y ^ 3 = softmax ( y 3 ) \hat{y}_3 = \text{softmax}(y_3) y^​3​=softmax(y3​)

假设真实输出为 ‘l’,对应 one-hot 编码为 y 3 = [ 0 , 0 , 1 , 0 ] y_3 = [0, 0, 1, 0] y3​=[0,0,1,0]。

交叉熵损失函数:

$$
\text{loss}3 = - \sum{i} y_{3i} \log(\hat{y}_{3

i})
$$

梯度计算:

∂ loss 3 ∂ W h y = ( y ^ 3 − y 3 ) h 3 T \frac{\partial \text{loss}_3}{\partial W_{hy}} = (\hat{y}_3 - y_3) h_3^T ∂Why​∂loss3​​=(y^​3​−y3​)h3T​

∂ loss 3 ∂ W x h = ∂ loss 3 ∂ h 3 ⋅ ∂ h 3 ∂ W x h \frac{\partial \text{loss}_3}{\partial W_{xh}} = \frac{\partial \text{loss}_3}{\partial h_3} \cdot \frac{\partial h_3}{\partial W_{xh}} ∂Wxh​∂loss3​​=∂h3​∂loss3​​⋅∂Wxh​∂h3​​

∂ loss 3 ∂ W h h = ∂ loss 3 ∂ h 3 ⋅ ∂ h 3 ∂ W h h \frac{\partial \text{loss}_3}{\partial W_{hh}} = \frac{\partial \text{loss}_3}{\partial h_3} \cdot \frac{\partial h_3}{\partial W_{hh}} ∂Whh​∂loss3​​=∂h3​∂loss3​​⋅∂Whh​∂h3​​

参数更新:

W x h = W x h − η ∂ loss 3 ∂ W x h W_{xh} = W_{xh} - \eta \frac{\partial \text{loss}_3}{\partial W_{xh}} Wxh​=Wxh​−η∂Wxh​∂loss3​​

W h h = W h h − η ∂ loss 3 ∂ W h h W_{hh} = W_{hh} - \eta \frac{\partial \text{loss}_3}{\partial W_{hh}} Whh​=Whh​−η∂Whh​∂loss3​​

W h y = W h y − η ∂ loss 3 ∂ W h y W_{hy} = W_{hy} - \eta \frac{\partial \text{loss}_3}{\partial W_{hy}} Why​=Why​−η∂Why​∂loss3​​

时间步 4(输入 ‘l’):

使用更新后的 W x h W_{xh} Wxh​、 W h h W_{hh} Whh​ 和 W h y W_{hy} Why​ 参数。

输入向量 x 4 = [ 0 , 0 , 1 , 0 ] x_4 = [0, 0, 1, 0] x4​=[0,0,1,0]

h 4 = tanh ⁡ ( W x h x 4 + W h h h 3 ) h_4 = \tanh(W_{xh} x_4 + W_{hh} h_3) h4​=tanh(Wxh​x4​+Whh​h3​)

计算后得:

h 4 = tanh ⁡ ( ( 0.5 1.2 ) + W h h h 3 ) h_4 = \tanh \left( \begin{pmatrix} 0.5 \\ 1.2 \end{pmatrix} + W_{hh} h_3 \right) h4​=tanh((0.51.2​)+Whh​h3​)

y 4 = W h y h 4 y_4 = W_{hy} h_4 y4​=Why​h4​

预测值 y ^ 4 = softmax ( y 4 ) \hat{y}_4 = \text{softmax}(y_4) y^​4​=softmax(y4​)

假设真实输出为 ‘o’,对应 one-hot 编码为 y 4 = [ 0 , 0 , 0 , 1 ] y_4 = [0, 0, 0, 1] y4​=[0,0,0,1]。

交叉熵损失函数:

loss 4 = − ∑ i y 4 i log ⁡ ( y ^ 4 i ) \text{loss}_4 = - \sum_{i} y_{4i} \log(\hat{y}_{4i}) loss4​=−i∑​y4i​log(y^​4i​)

梯度计算:

∂ loss 4 ∂ W h y = ( y ^ 4 − y 4 ) h 4 T \frac{\partial \text{loss}_4}{\partial W_{hy}} = (\hat{y}_4 - y_4) h_4^T ∂Why​∂loss4​​=(y^​4​−y4​)h4T​

∂ loss 4 ∂ W x h = ∂ loss 4 ∂ h 4 ⋅ ∂ h 4 ∂ W x h \frac{\partial \text{loss}_4}{\partial W_{xh}} = \frac{\partial \text{loss}_4}{\partial h_4} \cdot \frac{\partial h_4}{\partial W_{xh}} ∂Wxh​∂loss4​​=∂h4​∂loss4​​⋅∂Wxh​∂h4​​

∂ loss 4 ∂ W h h = ∂ loss 4 ∂ h 4 ⋅ ∂ h 4 ∂ W h h \frac{\partial \text{loss}_4}{\partial W_{hh}} = \frac{\partial \text{loss}_4}{\partial h_4} \cdot \frac{\partial h_4}{\partial W_{hh}} ∂Whh​∂loss4​​=∂h4​∂loss4​​⋅∂Whh​∂h4​​

参数更新:

W x h = W x h − η ∂ loss 4 ∂ W x h W_{xh} = W_{xh} - \eta \frac{\partial \text{loss}_4}{\partial W_{xh}} Wxh​=Wxh​−η∂Wxh​∂loss4​​

W h h = W h h − η ∂ loss 4 ∂ W h h W_{hh} = W_{hh} - \eta \frac{\partial \text{loss}_4}{\partial W_{hh}} Whh​=Whh​−η∂Whh​∂loss4​​

W h y = W h y − η ∂ loss 4 ∂ W h y W_{hy} = W_{hy} - \eta \frac{\partial \text{loss}_4}{\partial W_{hy}} Why​=Why​−η∂Why​∂loss4​​

4.代码实现

下面是一个使用 PyTorch 实现简单 RNN(循环神经网络)的示例代码,该代码将字符序列作为输入并预测下一个字符。我们将使用一个小的字符集进行演示。

安装 PyTorch

在开始之前,请确保您已安装 PyTorch。您可以使用以下命令进行安装:

pip install torch
RNN 实现示例

我们将实现一个字符级 RNN,用于从序列 “hello” 中预测下一个字符。字符集为 {‘h’, ‘e’, ‘l’, ‘o’}。

import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np

# 定义字符集和字符到索引的映射
chars = ['h', 'e', 'l', 'o']
char_to_idx = {ch: idx for idx, ch in enumerate(chars)}
idx_to_char = {idx: ch for idx, ch in enumerate(chars)}

# 超参数
input_size = len(chars)
hidden_size = 10
output_size = len(chars)
num_layers = 1
learning_rate = 0.01
num_epochs = 100

# 准备数据
def char_to_tensor(char):
    tensor = torch.zeros(input_size)
    tensor[char_to_idx[char]] = 1.0
    return tensor

def string_to_tensor(string):
    tensor = torch.zeros(len(string), input_size)
    for idx, char in enumerate(string):
        tensor[idx][char_to_idx[char]] = 1.0
    return tensor

input_seq = "hell"
target_seq = "ello"

input_tensor = string_to_tensor(input_seq)
target_tensor = torch.tensor([char_to_idx[ch] for ch in target_seq])

# 定义 RNN 模型
class RNN(nn.Module):
    def __init__(self, input_size, hidden_size, output_size):
        super(RNN, self).__init__()
        self.hidden_size = hidden_size
        self.rnn = nn.RNN(input_size, hidden_size, num_layers, batch_first=True)
        self.fc = nn.Linear(hidden_size, output_size)

    def forward(self, x, hidden):
        out, hidden = self.rnn(x, hidden)
        out = self.fc(out[:, -1, :])
        return out, hidden

    def init_hidden(self):
        return torch.zeros(num_layers, 1, hidden_size)

# 初始化模型、损失函数和优化器
model = RNN(input_size, hidden_size, output_size)
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=learning_rate)

# 训练模型
for epoch in range(num_epochs):
    hidden = model.init_hidden()
    model.zero_grad()
    
    input_seq = input_tensor.unsqueeze(0)
    output, hidden = model(input_seq, hidden)
    
    loss = criterion(output, target_tensor.unsqueeze(0))
    loss.backward()
    optimizer.step()
    
    if (epoch + 1) % 10 == 0:
        print(f'Epoch [{epoch + 1}/{num_epochs}], Loss: {loss.item():.4f}')

# 测试模型
def predict(model, char, hidden=None):
    if hidden is None:
        hidden = model.init_hidden()
    input_tensor = char_to_tensor(char).unsqueeze(0).unsqueeze(0)
    output, hidden = model(input_tensor, hidden)
    _, predicted_idx = torch.max(output, 1)
    return idx_to_char[predicted_idx.item()], hidden

hidden = model.init_hidden()
input_char = 'h'
predicted_seq = input_char
for _ in range(len(input_seq)):
    next_char, hidden = predict(model, input_char, hidden)
    predicted_seq += next_char
    input_char = next_char

print(f'Predicted sequence: {predicted_seq}')
代码说明
  1. 数据准备

    • 我们定义了一个简单的字符集 {‘h’, ‘e’, ‘l’, ‘o’},并创建了字符到索引和索引到字符的映射。
    • char_to_tensor 函数将字符转换为 one-hot 向量。
    • string_to_tensor 函数将字符串转换为一系列 one-hot 向量。
  2. 定义 RNN 模型

    • RNN 类继承自 nn.Module,包含一个 RNN 层和一个全连接层。
    • forward 方法执行前向传播。
    • init_hidden 方法初始化隐藏状态。
  3. 训练模型

    • 我们使用交叉熵损失函数和 Adam 优化器。
    • 在每个训练周期,我们进行前向传播、计算损失、反向传播和参数更新。
  4. 测试模型

    • predict 函数根据给定的输入字符生成下一个字符。
    • 我们使用训练好的模型从字符 ‘h’ 开始生成一个字符序列。

运行该代码后,您将看到模型预测的字符序列,它会逐渐学会从输入序列中预测下一个字符。

标签:loss,partial,RNN,tanh,text,推演,pmatrix,深度,frac
From: https://blog.csdn.net/weixin_47552266/article/details/139659451

相关文章

  • ReentrantReadWriteLock:深度解析与源码探险
    1.概述ReentrantReadWriteLock是Java并发包java.util.concurrent.locks中的一个重要类,它提供了可重入的读写锁功能。与传统的互斥锁(如synchronized或ReentrantLock)不同,ReentrantReadWriteLock允许多个线程同时读取共享资源,但在写入时则要求独占锁。这种设计显著提高了在读......
  • ReentrantLock的非公平锁(NonfairSync)深度解析:源码之旅与实战策略
    1.引言在Java并发编程中,ReentrantLock作为一种可重入的互斥锁,提供了比synchronized更强大和灵活的功能。其中,NonfairSync作为ReentrantLock内部非公平锁的实现,其设计理念和源码实现都体现了对性能和公平性的权衡。2.NonfairSync概述非公平锁特性:新到达的线程在......
  • 人工智能、机器学习与深度学习的奥秘:探索三者的定义与差异
    1.1人工智能现今每天都有很多人工智能的文章发表,并且在最近两年愈演愈烈。网络上关于人工智能的定义有几种说法,我最喜欢的一个是,通常由人完成的智能任务的自动化。1.1.1人工智能发展史1956年,约翰·麦肯锡(JohnMcCarthy)主持召开了第一次人工智能的学术会议,并创造了人工智......
  • 深度学习网络结构之---Inception
    目录一、Inception名称的由来二、Inception结构 三、Inceptionv2四、Inceptionv3 1、深度网络的通用设计原则2.卷积分解(FactorizingConvolutions)3.对称卷积分解3.非对称卷积分解 五、Inceptionv4一、Inception名称的由来        Inception网络名......
  • 【目标检测】基于深度学习的车牌识别管理系统(含UI界面)【python源码+Pyqt5界面 MX_002
    系统简介:        车牌识别技术作为经典的机器视觉任务,具有广泛的应用前景。通过图像处理方法,车牌识别技术能够对车牌上的字符进行检测、定位和识别,从而实现计算机对车牌的智能化管理。在现实生活中,车牌识别系统已在小区停车场、高速公路出入口、监控区域和自动收费站......
  • 算法3.1—深度优先搜索
    P1219[USACO1.5]八皇后CheckerChallenge#includeusingnamespacestd;typedeflonglongll;intn,l[50],r[50],vis[50],a[50];intans;voiddfs(intx){if(x>n){if(ans<3)for(inti=1;i<=n;i++)cout<<a[i]<<''......
  • 基于python_CNN深度学习的路面故障瑕疵检测-含数据集+pyqt界面
    代码下载地址:https://download.csdn.net/download/qq_34904125/89383045本代码是基于pythonpytorch环境安装的。下载本代码后,有个requirement.txt文本,里面介绍了如何安装环境,环境需要自行配置。或可直接参考下面博文进行环境安装。深度学习环境安装教程-anaconda-python-......
  • 基于python_CNN深度学习的猫狗表情识别-含数据集+pyqt界面
    代码下载地址:https://download.csdn.net/download/qq_34904125/89383039本代码是基于pythonpytorch环境安装的。下载本代码后,有个requirement.txt文本,里面介绍了如何安装环境,环境需要自行配置。或可直接参考下面博文进行环境安装。深度学习环境安装教程-anaconda-python-......
  • Python遗传算法GA对长短期记忆LSTM深度学习模型超参数调优分析司机数据
    全文链接:https://tecdat.cn/?p=36004原文出处:拓端数据部落公众号随着大数据时代的来临,深度学习技术在各个领域中得到了广泛的应用。长短期记忆(LSTM)网络作为深度学习领域中的一种重要模型,因其对序列数据的强大处理能力,在自然语言处理、时间序列预测等领域中取得了显著的成果。然......
  • 【课程总结】Day8(上):深度学习基本流程
    前言在上一篇课程《【课程总结】Day7:深度学习概述》中,我们了解到:模型训练过程→本质上是固定w和b参数的过程;让模型更好→本质上就是让模型的损失值loss变小;让loss变小→本质上就是求loss函数的最小值;本篇文章,我们将继续深入了解深度学习的项目流程,包括:批量化打包数据、模......