我正在尝试使用 tensorflow 进行研究,但我不明白如何打开和使用早期保存在文件中的类型为 tf.Graph 的图形。像这样的东西:
import tensorflow as tf
my_graph = tf.Graph()
with g.as_default():
x = tf.Variable(0)
b = tf.constant(-5)
k = tf.constant(2)
y = k*x + b
tf.train.write_graph(my_graph, '.', 'graph.pbtxt')
f = open('graph.pbtxt', "r")
# Do something with "f" to get my saved graph and use it below in
# tf.Session(graph=...) instead of dots
with tf.Session(graph=...) as sess:
tf.initialize_all_variables().run()
y1 = sess.run(y, feed_dict={x: 5})
y2 = sess.run(y, feed_dict={x: 10})
print(y1, y2)
Run Code Online (Sandbox Code Playgroud) 我试图理解Future::select:在这个例子中,首先返回具有较长时间延迟的未来.
当我通过它的例子阅读这篇文章时,我得到了认知失调.作者写道:
该
select函数运行两个(或者更多select_all)期货,并返回第一个完成.这对于实现超时很有用.
看来我不明白这种感觉select.
extern crate futures;
extern crate tokio_core;
use std::thread;
use std::time::Duration;
use futures::{Async, Future};
use tokio_core::reactor::Core;
struct Timeout {
time: u32,
}
impl Timeout {
fn new(period: u32) -> Timeout {
Timeout { time: period }
}
}
impl Future for Timeout {
type Item = u32;
type Error = String;
fn poll(&mut self) -> Result<Async<u32>, Self::Error> {
thread::sleep(Duration::from_secs(self.time as u64));
println!("Timeout is done with time {}.", …Run Code Online (Sandbox Code Playgroud) 我对我的 Rust 项目进行了基准测试cargo bench,结果看到了很多数字......它们是什么意思?
2 tests
test bench_few_core ... bench: 26,249,920 ns/iter (+/- 2,836,381)
test bench_one_core ... bench: 6,087,923 ns/iter (+/- 752,064)
Run Code Online (Sandbox Code Playgroud)
例如test bench_few_core,我看到:
它们都是什么意思?
我认为每个测试应该有 2 个数字:数学期望(或平均值)和标准偏差。