在官方文件中: example
class MultidimensionalRNNTest(tf.test.TestCase):
def setUp(self):
self.num_classes = 26
self.num_features = 32
self.time_steps = 64
self.batch_size = 1 # Can't be dynamic, apparently.
self.num_channels = 1
self.num_filters = 16
self.input_layer = tf.placeholder(tf.float32, [self.batch_size, self.time_steps, self.num_features, self.num_channels])
self.labels = tf.sparse_placeholder(tf.int32)
def test_simple_mdrnn(self):
net = lstm2d.separable_lstm(self.input_layer, self.num_filters)
def test_image_to_sequence(self):
net = lstm2d.separable_lstm(self.input_layer, self.num_filters)
net = lstm2d.images_to_sequence(net)
def test_convert_to_ctc_dims(self):
net = lstm2d.separable_lstm(self.input_layer, self.num_filters)
net = lstm2d.images_to_sequence(net)
net = tf.reshape(inputs, [-1, self.num_filters])
W = tf.Variable(tf.truncated_normal([self.num_filters,
self.num_classes],
stddev=0.1, dtype=tf.float32), name='W')
b = tf.Variable(tf.constant(0., dtype=tf.float32, shape=[self.num_classes], name='b'))
net = tf.matmul(net, W) + b
net = tf.reshape(net, [self.batch_size, -1, self.num_classes])
net = tf.transpose(net, (1, 0, 2))
loss = tf.nn.ctc_loss(inputs=net, labels=self.labels, sequence_length=[2])
print(net)
if __name__ == '__main__':
tf.test.main()
运算符有解释:
in运算符(而不是in,它的否定)。这是一个包含测试,用于查看某个值是否在集合中。例如,
in
我无法理解这个表达,但对它很感兴趣
它会检查name in {null,"Untitled"} || name
是name
还是null
。如果不是那么它返回"Untitled"
而不是布尔值,我是对的吗?
答案 0 :(得分:0)
这个OGNL表达的行为很奇怪
如果true
为null或name
,则返回"Untitled"
,否则如果在属性标记中使用,则返回name
的值。如果在if标记中使用,则仅当true
的值为name
或null
时,评估结果为"Untitled"
。
但我想知道这种表达可能会有什么用?