tensorflow越跑越慢_Tensorflow启动速度快,在训练过程中速度变慢

我是一名电气工程专业的学生,​​我试图根据锅炉内电阻器的功率,锅炉内水的温度和通过boiller使用python 3.5和tensorflow。 问题是,我是一个初学者在python和tensorflow,我写了这个代码可行,但训练开始快速而迅速地开始放慢速度,并且在训练中间开始在步骤之间花费时间。 我只是需要一些帮助的优化,当然,欢迎任何提示! 非常感谢! 下面是代码:Tensorflow启动速度快,在训练过程中速度变慢

import numpy as np

import tensorflow as tf

input_vec_size = 3

step_size = 0.05

batch_size = 3

test_size = 16

train_end = 1905

eval_end = 290

predict_end = 1396

n_cores = 4

def read_my_file_format(filename_queue):

line_reader = tf.TextLineReader(skip_header_lines=1)

_, csv_row = line_reader.read(filename_queue)

record_defaults = [[0.0], [0.0], [0.0], [0.0]]

time, power_in, temperature, flow = \

tf.decode_csv(csv_row, record_defaults=record_defaults)

features = tf.pack([

power_in,

temperature

])

return features, flow

def input_pipeline(directory, batch_size, n_cores, buffer_size, num_epochs=None):

filename_queue = tf.train.string_input_producer(

tf.train.match_filenames_once(directory),

shuffle=True)

features, flow = read_my_file_format(filename_queue)

x, y = tf.train.batch(

[features, flow], batch_size=batch_size, allow_smaller_final_batch=True)

def init_weights(shape):

return tf.Variable(tf.random_normal(shape, stddev=0.001))

def init_bias(shape): #inicializa bias

initial = tf.constant(0.001, shape=shape) #variancia 0.1

return tf.Variable(initial)

def model(X, w_h, w_h2, w_o, B, B2, B3, p_keep_input, p_keep_hidden):

X = tf.nn.dropout(X, p_keep_input)

h = tf.nn.relu(tf.matmul(X, w_h)+B)

h = tf.nn.dropout(h, p_ke

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值