# Dinosaurus Island - Character Level Language Model
## Gradient Clipping
* LSTMs handle vanishing gradient problems but not the Exploding Gradient Problems
* Gradient Clipping is one way to solve Exploding Gradient Problem
```python
def clip(gradients, maxValue):
'''
Clips the gradients' values between minimum and maximum.
Arguments:
gradients -- a dictionary containing the gradients "dWaa", "dWax", "dWya", "db", "dby"
maxValue -- everything above this number is set to this number, and everything less than -maxValue is set to -maxValue
Returns:
gradients -- a dictionary with the clipped gradients.
'''
# clip to mitigate exploding gradients, loop over [dWax, dWaa, dWya, db, dby]. (≈2 lines)
clipped_gradients = {}
for g in ['dWax', 'dWaa', 'dWya', 'db', 'dby']:
clipped_gradients[g] = np.clip(gradients[g], -maxValue, maxValue)
return clipped_gradients
```
## Sampling
* Numpy provides `np.random.choice` to perform sampling based on a probability distribution
```python
np.random.seed(0)
p = np.array([0.1, 0.0, 0.7, 0.2])
index = np.random.choice([0, 1, 2, 3], p = p.ravel())
```
## Optimization
```python
# Forward propagate through time (≈1 line)
loss, cache = rnn_forward(X, Y, a_prev, parameters)
# Backpropagate through time (≈1 line)
gradients, a = rnn_backward(X, Y, parameters, cache)
# Clip your gradients between -5 (min) and 5 (max) (≈1 line)
gradients = clip(gradients, 5)
# Update parameters (≈1 line)
parameters = update_parameters(parameters, gradients, learning_rate)
```
## Resources
* [Andrej Karpathy Implementation](https://gist.github.com/karpathy/d4dee566867f8291f086)
* [The Unreasonable Effectiveness of Recurrent Neural Networks](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)
* [Keras LSTM Text Generation](https://github.com/keras-team/keras/blob/master/examples/lstm_text_generation.py)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
网易云课堂的深度学习工程师微专业,神经网络和深度学习 改善深层神经网络:超参数调试、正则化以及优化结构化+源代码+文档说明 - - 小白不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 --------
资源推荐
资源详情
资源评论
收起资源包目录
网易云课堂的深度学习工程师微专业,神经网络和深度学习 改善深层神经网络:超参数调试、正则化以及优化结构化+源代码+文档说明 (116个子文件)
nn4.small2.v7.h5 14.65MB
Trigger+word+detection+-+v1-finished.ipynb 23.15MB
assignment4_2.ipynb 1.94MB
assignment4_2_答案.ipynb 1.87MB
Improvise+a+Jazz+Solo+with+an+LSTM+Network+-+v1-finished.ipynb 1.72MB
Art Generation with Neural Style Transfer - v2_答案.ipynb 438KB
Optimization+methods_答案.ipynb 384KB
assignment3_答案.ipynb 357KB
Residual Networks - v2答案.ipynb 336KB
assignment2_2_答案.ipynb 306KB
2.Regularization_答案.ipynb 298KB
1.Initialization_答案.ipynb 285KB
Autonomous driving application - Car detection - v1_答案.ipynb 267KB
Tensorflow+Tutorial_答案.ipynb 206KB
Neural+machine+translation+with+attention+-+v3-finished.ipynb 85KB
Building+a+Recurrent+Neural+Network+-+Step+by+Step+-+v3-finish.ipynb 84KB
Convolution model - Application - v1_答案.ipynb 83KB
Building+a+Recurrent+Neural+Network+-+Step+by+Step+-+v3-starter.ipynb 77KB
Emojify+-+v2-finished.ipynb 68KB
Convolution model - Step by Step - v2_答案.ipynb 58KB
Optimization+methods.ipynb 55KB
assignment4_1_答案.ipynb 54KB
Trigger+word+detection+-+v1-starter.ipynb 53KB
Tensorflow+Tutorial.ipynb 50KB
assignment4_1.ipynb 50KB
Keras - Tutorial - Happy House v2答案.ipynb 49KB
Convolution model - Step by Step - v2.ipynb 48KB
Autonomous driving application - Car detection - v1.ipynb 46KB
Dinosaurus+Island+--+Character+level+language+model+final+-+v3-finished.ipynb 45KB
Emojify+-+v2-starter.ipynb 44KB
Art Generation with Neural Style Transfer - v2.ipynb 44KB
assignment3.ipynb 43KB
assignment2_1_答案.ipynb 40KB
assignment2_2.ipynb 39KB
2.Regularization.ipynb 38KB
Dinosaurus+Island+--+Character+level+language+model+final+-+v3-starter.ipynb 37KB
Residual Networks - v2.ipynb 35KB
Operations+on+word+vectors+-+v2-finished.ipynb 33KB
assignment2_1.ipynb 33KB
Face Recognition for the Happy House - v3_答案.ipynb 32KB
Neural+machine+translation+with+attention+-+v3-starter.ipynb 32KB
Face Recognition for the Happy House - v3.ipynb 30KB
Improvise+a+Jazz+Solo+with+an+LSTM+Network+-+v1-starter.ipynb 29KB
Operations+on+word+vectors+-+v2-starter.ipynb 29KB
Convolution model - Application - v1.ipynb 27KB
3.Gradient+Checking.ipynb 26KB
3.Gradient+Checking_答案.ipynb 26KB
1.Initialization.ipynb 25KB
Keras - Tutorial - Happy House v2.ipynb 17KB
README.md 2KB
README.md 2KB
README.md 1KB
README.md 51B
tune1.midi 137B
attn_model.png 271KB
attn_mechanism.png 168KB
date_attention.png 131KB
date_attention2.png 130KB
table.png 87KB
poorly_trained_model.png 10KB
main.py 18KB
main.py 16KB
grammar.py 15KB
main.py 14KB
main.py 13KB
main.py 12KB
inception_blocks.py 11KB
inception_blocks_v2.py 11KB
reg_utils.py 10KB
main.py 10KB
main.py 10KB
main.py 9KB
fr_utils.py 8KB
main.py 8KB
main.py 8KB
opt_utils.py 8KB
init_utils.py 7KB
nmt_utils.py 7KB
nst_utils.py 7KB
main.py 6KB
data_utils.py 6KB
testCases_v2.py 6KB
preprocess.py 6KB
main.py 6KB
main.py 6KB
cnn_utils.py 6KB
test.py 5KB
testCases.py 5KB
testCases.py 5KB
rnn_utils.py 5KB
shakespeare_utils.py 5KB
w2v_utils.py 5KB
main.py 5KB
resnets_utils.py 5KB
tf_utils.py 5KB
utils.py 5KB
utils.py 4KB
planar_utils.py 4KB
emo_utils.py 4KB
midi.py 4KB
共 116 条
- 1
- 2
资源评论
机智的程序员zero
- 粉丝: 2416
- 资源: 4812
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- YOLOv8完整网络结构图详细visio
- LCD1602电子时钟程序
- 西北太平洋热带气旋【灾害风险统计】及【登陆我国次数评估】数据集-1980-2023
- 全球干旱数据集【自校准帕尔默干旱程度指数scPDSI】-190101-202312-0.5x0.5
- 基于Python实现的VAE(变分自编码器)训练算法源代码+使用说明
- 全球干旱数据集【标准化降水蒸发指数SPEI-12】-190101-202312-0.5x0.5
- C语言小游戏-五子棋-详细代码可运行
- 全球干旱数据集【标准化降水蒸发指数SPEI-03】-190101-202312-0.5x0.5
- spring boot aop记录修改前后的值demo
- 全球干旱数据集【标准化降水蒸发指数SPEI-01】-190101-202312-0.5x0.5
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功