blocks_test.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:fold 作者: tensorflow 项目源码 文件源码
def test_record_doc_example(self):
    # Test to make sure examples from the documentation compile.
    example_datum = {'id': 8,
                     'name': 'Joe Smith',
                     'location': (2.5, 7.0)}
    num_ids = 16
    embed_len = 16
    td = tdb
    char_rnn = (td.InputTransform(lambda s: [ord(c) for c in s]) >>
                td.Map(td.Scalar('int32') >>
                       td.Function(tdl.Embedding(128, 16))) >>
                td.Fold(td.Concat() >> td.Function(tdl.FC(32)),
                        td.FromTensor(tf.zeros(32))))
    r = (td.Record([('id', (td.Scalar('int32') >>
                            td.Function(tdl.Embedding(num_ids, embed_len)))),
                    ('name', char_rnn),
                    ('location', td.Vector(2))])
         >> td.Concat() >> td.Function(tdl.FC(256)))
    with self.test_session():
      r.eval(example_datum)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号