【发布时间】:2017-08-10 20:21:58
【问题描述】:
我通过 tensorflow 制作去噪自动编码器。
我使用 799x161 矩阵作为输入数据。
这是我的训练代码
training_epochs = 100
batch_size = 799
display_step = 10
# Training
if do_train:
print ("Training Start")
for epoch in range(training_epochs):
avg_cost = 0.
num_batch = int(X_train.shape[0]/batch_size)
for i in range(num_batch):
batch = X_train[i*batch_size : i*batch_size+batch_size]
batch_noise = batch + 0.3*np.random.randn(batch.shape[0], 161) #addnoise
feed1 = {x: batch_noise, y_: batch, keep_prob: 0.5}
sess.run(optimizer, feed_dict = feed1)
feed2 = {x: batch_noise, y_: batch, keep_prob: 1}
avg_cost += sess.run(cost, feed_dict=feed2)/num_batch
if epoch % display_step == 0:
print ("Epoch: %03d/%03d cost: %.9f" % (epoch, training_epochs, avg_cost))
和测试代码
# TEST
testspeech = scipy.io.loadmat('data/test_cep.mat')
Y_test = testspeech['ans']
Y_test = np.array(Y_test) # 799x161 cepstrum matrix
noisyspeech = scipy.io.loadmat('data/reverb_cep.mat')
Y_noisy = noisyspeech['ans']
Y_noisy = np.array(Y_noisy) # 799x161 cepstrum addnoise matrix
batch = Y_test
batch_noise = Y_noisy
avg_cost += sess.run(cost, feed_dict=feed2)/num_batch
print ("cost: %.9f" % (avg_cost))
测试后,我想将输出文件保存为 799x161 矩阵,以便与干净的数据进行比较并在 matlab 中处理。
我的问题:但我不知道如何将其保存为矩阵。我的意思是我想在我的电脑中将矩阵保存为可读文件。我不确定 matlab 是否可以读取它。
【问题讨论】:
标签: tensorflow