python - tensorflow 1.8 版中 tf.contrib.seq2seq.prepare_attention() 的替代方案
问题描述
AttributeError:模块“tensorflow.contrib.seq2seq”没有属性“prepare_attention”
我知道 prepare_attention() 已被弃用。有什么替代方案?并且还请指定语法。
我正在使用的函数是:defdecode_layer_train(encoder_state,dec_cell,dec_embed_input,sequence_length,decode_scope,output_fn,keep_prob,batch_size):'''解码训练数据'''
attention_states = tf.zeros([batch_size, 1, dec_cell.output_size])
att_keys, att_vals, att_score_fn, att_construct_fn = tf.contrib.seq2seq.prepare_attention(attention_states,
attention_option="bahdanau",
num_units=dec_cell.output_size)
train_decoder_fn = tf.contrib.seq2seq.attention_decoder_fn_train(encoder_state[0],
att_keys,
att_vals,
att_score_fn,
att_construct_fn,
name = "attn_dec_train")
train_pred, _, _ = tf.contrib.seq2seq.dynamic_rnn_decoder(dec_cell,
train_decoder_fn,
dec_embed_input,
sequence_length,
scope=decoding_scope)
train_pred_drop = tf.nn.dropout(train_pred, keep_prob)
return output_fn(train_pred_drop)
解决方案
推荐阅读
- javascript - Flutter - 谷歌地图,不显示我的位置
- typescript - STS 不是构造函数
- r - 安装包“ggplot2”的退出状态非零
- ruby-on-rails - Rails - REGEX - 验证非空格/特殊字符的长度
- javascript - 来自 javascript 的带有发布数据的新 Razor 页面
- javascript - 如何使用 exec 通过 SSH 或 HTTPS 进行身份验证
- java - 在 Eclipse 中运行一个内置于 docker 的项目
- r - 使用 R 来确定期刊中的作者位置?
- python - Bokeh DataTable - 在选择回调时返回行和列
- java - 由于未暂存的更改,出现“无法锁定配置文件 .git/config:权限被拒绝”的错误;在 Homebrew 中安装 openJDK 8