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)
评论列表
文章目录