91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小:
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-06-18
  • 語言: Python
  • 標(biāo)簽: nlp??

資源簡(jiǎn)介

python 自然語言處理實(shí)戰(zhàn)代碼部分

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
#?@Time?????????:?2018-07-30?22:48
#?@Author???????:?Jayce?Wong
#?@ProjectName??:?NLP
#?@FileName?????:?dynamic_seq2seq_model.py
#?@Blog?????????:?http://blog.51cto.com/jayce1111
#?@Github???????:?https://github.com/SysuJayce

######################################################################
#???????不知作者為啥用的TensorFlow1.0,明明出書的時(shí)候都2018年了
#????????暫時(shí)先把作者代碼放上來,等水平上來了看看怎么改成1.8或者1.9版本
#????????現(xiàn)在這份代碼跑不動(dòng)
######################################################################

import?math
import?tensorflow?as?tf
import?tensorflow.contrib.seq2seq?as?seq2seq
from?tensorflow.contrib.rnn?import?LSTMStateTuple


class?DynamicSeq2Seq:
????PAD?=?0
????EOS?=?2
????UNK?=?3

????def?__init__(self?encoder_cell?decoder_cell?encoder_vocab_size
?????????????????decoder_vocab_size?embedding_size?bidirectional=True
?????????????????attention=False?debug=False?time_major=False):
????????self.debug?=?debug
????????self.bidirectional?=?bidirectional
????????self.attention?=?attention

????????self.encoder_vocab_size?=?encoder_vocab_size
????????self.decoder_vocab_size?=?decoder_vocab_size

????????self.embedding_size?=?embedding_size

????????self.encoder_cell?=?encoder_cell
????????self.decoder_cell?=?decoder_cell

????????self.global_step?=?tf.Variable(-1?trainable=False)
????????self.max_gradient_norm?=?5
????????self.time_major?=?time_major

????????self._make_graph()??#?創(chuàng)建模型?

????@property
????def?decoder_hidden_units(self):
????????return?self.decoder_cell.output_size

????def?_make_graph(self):
????????self._init_placeholders()

????????self._init_decoder_train_connectors()

????????self._init_embeddings()

????????if?self.bidirectional:
????????????self._init_bidirectional_encoder()
????????else:
????????????self._init_simple_encoder()

????????self._init_decoder()

????????self._init_optimizer()

????def?_init_placeholders(self):
????????self.encoder_inputs?=?tf.placeholder(dtype=tf.int32?shape=(None?None)
?????????????????????????????????????????????name=‘encoder_inputs‘)
????????self.encoder_inputs_length?=?tf.placeholder(
????????????dtype=tf.int32?shape=(None)?name=‘encoder_inputs_length‘)
????????self.decoder_targets?=?tf.placeholder(dtype=tf.int32
??????????????????????????????????????????????shape=(None?None)
??????????????????????????????????????????????name=‘decoder_targets‘)
????????self.decoder_targets_length?=?tf.placeholder(
????????????dtype=tf.int32?shape=(None)?name=‘decoder_targets_length‘)

????def?_init_decoder_train_connectors(self):
????????with?tf.name_scope(‘DecoderTrainFeeds‘):
????????????sequence_size?batch_size?=?tf.unstack(
????????????????tf.shape(self.decoder_targets))
????????????EOS_SLICE?=?tf.ones([1?batch_size]?dtype=tf.int32)?*?self.EOS
????????????PAD_SLICE?=?tf.ones([1?batch_size]?dtype=tf.int32)?*?self.PAD

????????????self.decoder_train_inputs?=?tf.concat(
????????????????[EOS_SLICE?self.decoder_targets]?axis=0)
????????????self.decoder_train_length?=?self.decoder_targ

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\
?????文件?????????621??2018-07-30?16:13??NLP_learn-master\README.md
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter10\
?????文件???????11885??2018-07-30?16:13??NLP_learn-master\chapter10\dynamic_seq2seq_model.py
?????文件???????14718??2018-07-30?16:13??NLP_learn-master\chapter10\main.py
?????文件????????3636??2018-07-30?16:13??NLP_learn-master\chapter10\preprocessing.py
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter3\
?????文件???????14711??2018-07-30?16:13??NLP_learn-master\chapter3\cut_word.py
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter3\data\
?????文件??????232266??2018-07-30?16:13??NLP_learn-master\chapter3\data\hmm_model.pkl
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter4\
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\
?????文件??????????28??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\AUTHORS
?????文件????????1494??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\BSD
?????文件?????????164??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\COPYING
?????文件???????26428??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\LGPL
?????文件??????????20??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\README
?????文件???????50688??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\crf_learn.exe
?????文件???????50688??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\crf_test.exe
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\
?????文件????????3243??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\default.css
?????目錄???????????0??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\
?????文件????????2197??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\annotated.html
?????文件?????????677??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\bc_s.png
?????文件????????4317??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\classCRFPP_1_1Model-members.html
?????文件???????11478??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\classCRFPP_1_1Model.html
?????文件???????15210??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\classCRFPP_1_1Tagger-members.html
?????文件???????54951??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\classCRFPP_1_1Tagger.html
?????文件????????2932??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\classes.html
?????文件?????????126??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\closed.png
?????文件???????45954??2018-07-30?16:13??NLP_learn-master\chapter4\CRF++-0.58\doc\doxygen\crfpp_8h-source.html
............此處省略106個(gè)文件信息

評(píng)論

共有 條評(píng)論