【发布时间】:2017-07-03 09:30:29
【问题描述】:
我正在尝试生成一个基于标量输入的数学运算选择 nn 模型。该操作是根据 nn 产生的 softmax 结果来选择的。然后必须将此操作应用于标量输入以产生最终输出。到目前为止,我已经想出在 softmax 输出上应用 argmax 和 onehot 以生成一个掩码,然后将它应用于所有可能执行的操作的连接值矩阵(如下面的伪代码所示)。问题是 argmax 和 onehot 似乎都不可区分。我是新手,所以任何人都会受到高度赞赏。提前致谢。
#perform softmax
logits = tf.matmul(current_input, W) + b
softmax = tf.nn.softmax(logits)
#perform all possible operations on the input
op_1_val = tf_op_1(current_input)
op_2_val = tf_op_2(current_input)
op_3_val = tf_op_2(current_input)
values = tf.concat([op_1_val, op_2_val, op_3_val], 1)
#create a mask
argmax = tf.argmax(softmax, 1)
mask = tf.one_hot(argmax, num_of_operations)
#produce the input, by masking out those operation results which have not been selected
output = values * mask
【问题讨论】:
标签: machine-learning tensorflow neural-network recurrent-neural-network calculus