tensorflow第6次练习:RNN的应用--创作诗篇
发布时间
阅读量:
阅读量
RNN作为一种具有高度效能的神经网络架构,其输入与输出均表现为向量序列的形式。该模型专门针对序列数据的建模需求而设计,已被广泛应用于视频、图像和文本等各类序列信息的处理任务中。在本文中,我们将通过一个具体的实例来展示RNN的应用方式——利用RNN生成古典诗词。
数据来源:poetry.txt
- 训练脚本 train.py
# -*- coding: utf-8 -*-
import collections
import tensorflow as tf
import numpy as np
poetry_file ="poetry.txt"
#诗集
poetrys = []
with open(poetry_file,"r",encoding = "utf-8") as f:
for line in f:
try:
title,content=line.strip().split(":")
content = content.replace(' ','')
if '_' in content or '(' in conte
全部评论 (0)
还没有任何评论哟~
