作家
登录

漫谈四种神经网络序列解码模型以及示例代码

作者: 来源: 2017-04-25 13:04:28 阅读 我要评论

  •                 , 'twenty_one twenty_two twenty_three twenty_four twenty_five']    
  •   
  •     input_list = []    
  •     tar_list = []    
  •   
  •     for tmp_input in input_text:    
  •         input_list.append(tokenize(tmp_input))    
  •     for tmp_tar in tar_text:    
  •         tar_list.append(tokenize(tmp_tar))    
  •   
  •     vocab = sorted(reduce(lambda x, y: x | y, (set(tmp_list) for tmp_list in input_list   tar_list)))    
  •     # Reserve 0 for masking via pad_sequences    
  •     vocab_size = len(vocab)   1  # keras进行embedding的时刻必须进行len(vocab) 1    
  •     input_maxlen = max(map(len, (x for x in input_list)))    
  •     tar_maxlen = max(map(len, (x for x in tar_list)))    
  •     output_dim = vocab_size    
  •     hidden_dim = 20    
  •   
  •     print(‘-’)    
  •     print(‘Vocab size:’, vocab_size, ’unique words’)    
  •     print(‘Input max length:’, input_maxlen, ’words’)    
  •     print(‘Target max length:’, tar_maxlen, ’words’)    
  •     print(‘Dimension of hidden vectors:’, hidden_dim)    
  •     print(‘Number of training stories:’, len(input_list))    
  •     print(‘Number of test stories:’, len(input_list))    
  •     print(‘-’)    
  •     print(‘Vectorizing the word sequences…’)    
  •     word_to_idx = dict((c, i   1) for i, c in enumerate(vocab))  # 编码时须要将字符映射成数字index    
  •     idx_to_word = dict((i   1, c) 

      推荐阅读

      如何使用batch-import工具向neo4j中导入海量数据

    【引自T_SevenS的博客】在开辟neo4j的过程中,经常会有同窗问若何向neo4j中导入大年夜量的汗青数据,而这些数据一般都邑存在于关系型数据库中,如今本人就根据本身的导入经历,把导入的过>>>详细阅读


    本文标题:漫谈四种神经网络序列解码模型以及示例代码

    地址:http://www.17bianji.com/lsqh/34942.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)