-
大小: 1.18MB文件类型: .zip金币: 2下载: 0 次发布日期: 2023-11-18
- 语言: Python
- 标签:
资源简介
Deep Reinforcement Learning For Sequence to Sequence Models

代码片段和文件信息
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
# Modifications Copyright 2017 Abigail See
#
# Licensed under the Apache License Version 2.0 (the “License“);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an “AS IS“ BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
“““This file defines the decoder“““
import tensorflow as tf
from tensorflow.python.ops import variable_scope
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import nn_ops
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops.distributions import categorical
from tensorflow.python.ops.distributions import bernoulli
from rouge_tensor import rouge_l_fscore
FLAGS = tf.app.flags.FLAGS
def print_shape(str var):
tf.logging.info(‘shape of {}: {}‘.format(str [k for k in var.get_shape()]))
def _calc_final_dist(_hps v_size _max_art_oovs _enc_batch_extend_vocab p_gen vocab_dist attn_dist):
“““Calculate the final distribution for the pointer-generator model
Args:
vocab_dists: The vocabulary distributions. List length max_dec_steps of (batch_size vsize) arrays. The words are in the order they appear in the vocabulary file.
attn_dists: The attention distributions. List length max_dec_steps of (batch_size max_enc_steps) arrays
Returns:
final_dists: The final distributions. List length max_dec_steps of (batch_size extended_vsize) arrays.
“““
with tf.variable_scope(‘final_distribution‘):
# Multiply vocab dists by p_gen and attention dists by (1-p_gen)
vocab_dist = p_gen * vocab_dist
attn_dist = (1-p_gen) * attn_dist
# Concatenate some zeros to each vocabulary dist to hold the probabilities for in-article OOV words
extended_vsize = v_size + _max_art_oovs # the maximum (over the batch) size of the extended vocabulary
extra_zeros = tf.zeros((_hps.batch_size _max_art_oovs))
vocab_dists_extended = tf.concat(axis=1 values=[vocab_dist extra_zeros]) # list length max_dec_steps of shape (batch_size extended_vsize)
# Project the values in the attention distributions onto the appropriate entries in the final distributions
# This means that if a_i = 0.1 and the ith encoder word is w and w has index 500 in the vocabulary then we add 0.1 onto the 500th entry of the final distribution
# This is done for each decoder timestep.
# This is fiddly; we use tf.scatter_nd to do the projection
batch_nums = tf.range(0 limit=_hps.batch_size) # shape (batch_size)
batch_nums = tf.expan
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-06-18 20:31 RLSeq2Seq-master\
文件 3221 2019-06-18 20:31 RLSeq2Seq-master\CODE_OF_CONDUCT.md
文件 1714 2019-06-18 20:31 RLSeq2Seq-master\CONTRIBUTING.rst
文件 1073 2019-06-18 20:31 RLSeq2Seq-master\LICENSE.txt
文件 30301 2019-06-18 20:31 RLSeq2Seq-master\README.rst
目录 0 2019-06-18 20:31 RLSeq2Seq-master\docs\
文件 8196 2019-06-18 20:31 RLSeq2Seq-master\docs\.DS_Store
目录 0 2019-06-18 20:31 RLSeq2Seq-master\docs\_img\
文件 6148 2019-06-18 20:31 RLSeq2Seq-master\docs\_img\.DS_Store
文件 146506 2019-06-18 20:31 RLSeq2Seq-master\docs\_img\rlseq.png
文件 166086 2019-06-18 20:31 RLSeq2Seq-master\docs\_img\selfcritic.png
文件 68612 2019-06-18 20:31 RLSeq2Seq-master\docs\_img\seq2seq.png
文件 60 2019-06-18 20:31 RLSeq2Seq-master\python_requirements.txt
目录 0 2019-06-18 20:31 RLSeq2Seq-master\results\
文件 1449 2019-06-18 20:31 RLSeq2Seq-master\results\nointradecoder-notemporal-withpretraining-after-RL.txt
文件 1448 2019-06-18 20:31 RLSeq2Seq-master\results\nointradecoder-notemporal-withpretraining-before-RL.txt
文件 6331 2019-06-18 20:31 RLSeq2Seq-master\results\sc
目录 0 2019-06-18 20:31 RLSeq2Seq-master\src\
文件 8196 2019-06-18 20:31 RLSeq2Seq-master\src\.DS_Store
文件 0 2019-06-18 20:31 RLSeq2Seq-master\src\__init__.py
文件 38545 2019-06-18 20:31 RLSeq2Seq-master\src\attention_decoder.py
文件 18476 2019-06-18 20:31 RLSeq2Seq-master\src\batcher.py
文件 10537 2019-06-18 20:31 RLSeq2Seq-master\src\beam_search.py
文件 12760 2019-06-18 20:31 RLSeq2Seq-master\src\data.py
文件 11926 2019-06-18 20:31 RLSeq2Seq-master\src\decode.py
文件 6493 2019-06-18 20:31 RLSeq2Seq-master\src\dqn.py
文件 843 2019-06-18 20:31 RLSeq2Seq-master\src\file_spliter.py
文件 681215 2019-06-18 20:31 RLSeq2Seq-master\src\filter_files.txt
目录 0 2019-06-18 20:31 RLSeq2Seq-master\src\helper\
文件 3989 2019-06-18 20:31 RLSeq2Seq-master\src\helper\README.rst
文件 3796 2019-06-18 20:31 RLSeq2Seq-master\src\helper\cnn_dm_data_maker.py
............此处省略13个文件信息
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Python-DeepMoji模型的pyTorch实现
- Python-使用DeepFakes实现YouTube视频自动换
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- Python-自然场景文本检测PSENet的一个
- Python-在特征金字塔网络FPN的Pytorch实现
- Python-PyTorch实时多人姿态估计项目的实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-心脏核磁共振MRI图像分割
- Python-基于YOLOv3的行人检测
- Python-PyTorch对卷积CRF的参考实现
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
- Python-UNet用于医学图像分割的嵌套UN
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-Keras实现Inceptionv4InceptionResnetv1和
- Python-pytorch中文手册
- Python-FastSCNN的PyTorch实现快速语义分割
- Python-滑动窗口高分辨率显微镜图像分
- Python-使用MovieLens数据集训练的电影推
- Python-机器学习驱动的Web应用程序防火
- Python-subpixel利用Tensorflow的一个子像素
-
Python-汉字的神经风格转移Neuralst
y - Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-STGAN用于图像合成的空间变换生
评论
共有 条评论