我无法使用java将1715UTC转换为local / gmt类型 我被试了
temptime= "1715UTC"
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" HH:mm");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date myDate = simpleDateFormat.parse(temptime);
time= Long.toString(myDate.getTime());
但是我得到了java.text.ParseException:Unparseable date:" 1715" 请帮我理清这个
答案 0 :(得分:0)
您的格式错误。您的格式为rnn_size = 2
time_step_size = 23
batch_size = 1
rnn_cell = tf.nn.rnn_cell.BasicLSTMCell(rnn_size)
state = rnn_cell.zero_state(batch_size, tf.float32)
for i in range(len(x_data)):
x = process_x(x_data[i])[:23]
y = word[i][:23]
x_split = tf.split(0, time_step_size, x)
outputs, state = tf.nn.rnn(rnn_cell, x_split, state)
prediction = tf.reshape(tf.concat(1, outputs), [-1, rnn_size])
real = tf.reshape(y, [-1])
ratio = tf.ones([time_step_size * batch_size])
loss = tf.nn.seq2seq.sequence_loss_by_example([prediction], [real], [ratio])
cost = tf.reduce_mean(loss)/batch_size
train = tf.train.AdamOptimizer(0.01).minimize(cost)
# h_loss = tf.summary.scalar('loss', loss)
h_cost = tf.summary.scalar('cost', cost)
merged = tf.summary.merge_all()
with tf.Session() as sess:
tf.global_variables_initializer().run()
writer = tf.summary.FileWriter("../NLP_tensorboards/"+__file__.split('/')[-1], sess.graph)
for step in range(10000):
sess.run(train)
summary = sess.run(merged)
writer.add_summary(summary, step)
result = sess.run(tf.arg_max(prediction, 1))
# print [t for t in result] == word[gap:]
# print ''.join([char_rdic[t] for t in result])
# print result, word[gap:], x_data[gap:], x_data
print result, [t for t in result] == y
而不是HHmm
以下是更正的代码
HH:mm
这是一个带有类似代码的ideone,以带有正确输出的字符串格式显示结果(17:15)。