【发布时间】:2018-04-01 06:16:15
【问题描述】:
我正在研究一种用于语音增强的 RNN 架构。输入的维度是[XX, X, 1024],其中XX 是批量大小,X 是可变序列长度。
网络的输入是正值数据,输出是经过掩码的二进制数据(IBM),后来用于构建增强信号。
例如,如果网络的输入是 [10, 65, 1024],则输出将是带有二进制值的 [10,65,1024] 张量。我正在使用具有均方误差的 Tensorflow 作为损失函数。但我不确定在这里使用哪个激活函数(保持输出为零或一),以下是我到目前为止提出的代码
tf.reset_default_graph()
num_units = 10 #
num_layers = 3 #
dropout = tf.placeholder(tf.float32)
cells = []
for _ in range(num_layers):
cell = tf.contrib.rnn.LSTMCell(num_units)
cell = tf.contrib.rnn.DropoutWrapper(cell, output_keep_prob = dropout)
cells.append(cell)
cell = tf.contrib.rnn.MultiRNNCell(cells)
X = tf.placeholder(tf.float32, [None, None, 1024])
Y = tf.placeholder(tf.float32, [None, None, 1024])
output, state = tf.nn.dynamic_rnn(cell, X, dtype=tf.float32)
out_size = Y.get_shape()[2].value
logit = tf.contrib.layers.fully_connected(output, out_size)
prediction = (logit)
flat_Y = tf.reshape(Y, [-1] + Y.shape.as_list()[2:])
flat_logit = tf.reshape(logit, [-1] + logit.shape.as_list()[2:])
loss_op = tf.losses.mean_squared_error(labels=flat_Y, predictions=flat_logit)
#adam optimizier as the optimization function
optimizer = tf.train.AdamOptimizer(learning_rate=0.001) #
train_op = optimizer.minimize(loss_op)
#extract the correct predictions and compute the accuracy
correct_pred = tf.equal(tf.argmax(prediction, 1), tf.argmax(Y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
我的重建也不好。有人可以建议改进模型吗?
【问题讨论】:
-
抱歉,回复太晚了,我实际上使用了 MSE 损失函数,我把输入张量值弄乱了,这就是它没有按预期工作的原因。总之谢谢你
标签: python-3.x tensorflow deep-learning lstm recurrent-neural-network