作家
登录

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

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

  •             continue  # empty list was found    
  •         if truncating == ’pre’:    
  •             trunc = s[-maxlen:]    
  •         elif truncating == ’post’:    
  •             trunc = s[:maxlen]    
  •         else:    
  •             raise ValueError(‘Truncating type ”%s” not understood’ % truncating)    
  •   
  •         # check `trunc` has expected shape    
  •         trunc = np.asarray(trunc, dtype=dtype)    
  •         if trunc.shape[1:] != sample_shape:    
  •             raise ValueError(‘Shape of sample %s of sequence at position %s is different from expected shape %s’ %    
  •                              (trunc.shape[1:], idx, sample_shape))    
  •   
  •         if padding == ’post’:    
  •             x[idx, :len(trunc)] = trunc    
  •         elif padding == ’pre’:    
  •             x[idx, -len(trunc):] = trunc    
  •         else:    
  •             raise ValueError(‘Padding type ”%s” not understood’ % padding)    
  •     return x    
  •   
  •   
  • def vectorize_stories(input_list, tar_list, word_idx, input_maxlen, tar_maxlen, vocab_size):    
  •     x_set = []    
  •     Y = np.zeros((len(tar_list), tar_maxlen, vocab_size), dtype=np.bool)    
  •     for _sent in input_list:    
  •         x = [word_idx[w] for w in _sent]    
  •         x_set.append(x)    

      推荐阅读

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

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


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

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

  • 关键词: 探索发现

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

    网友点评
    自媒体专栏

    评论

    热度

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