无法理解运算符中的OGNL表达式

时间:2018-01-18 07:55:12

标签: struts2 ognl

在官方文件中: 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"} || namename还是null。如果不是那么它返回"Untitled"而不是布尔值,我是对的吗?

1 个答案:

答案 0 :(得分:0)

这个OGNL表达的行为很奇怪 如果true为null或name,则返回"Untitled",否则如果在属性标记中使用,则返回name的值。如果在if标记中使用,则仅当true的值为namenull时,评估结果为"Untitled"。 但我想知道这种表达可能会有什么用?