假设我们有两种不同的链码:cc1和cc2.
如果CC1调用CC2是有办法的α2来检查是否调用是来自CC1.
我试图按照他们的长度对我的训练样例进行分组:https://www.tensorflow.org/versions/r0.12/api_docs/python/contrib.training/bucketing
但我想使用新的Data API.所以我想知道有没有办法做到这一点.
这是我的代码:
import tensorflow as tf
vocabulary = ["This", "is", "my", "first", "example",
"the", "second", "one","How", "to", "bucket",
"examples", "using", "new", "Data", "API"]
data = ["This is my first example",
"How to bucket my examples using the new Data API",
"This is the second one",
"How to bucket my examples using the new Data API"]
BATCH_SIZE = 2
lookup_table = tf.contrib.lookup.index_table_from_tensor(vocabulary)
dataset = tf.data.Dataset.from_tensor_slices(data)
def tokenize(x):
words = tf.string_split([x], " ").values
return words
def lookup(x): …
Run Code Online (Sandbox Code Playgroud)