小编Ser*_*gey的帖子

从文件打开张量流图

我正在尝试使用 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)

python graph tensorflow

5
推荐指数
2
解决办法
1万
查看次数

为什么Future :: select首先选择睡眠时间较长的未来?

我试图理解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)

select future rust

4
推荐指数
1
解决办法
1195
查看次数

我如何解释`cargo bench`的输出?

我对我的 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,我看到:

  • 数字 1 = 26
  • 数字 2 = 249
  • 数字 3 = 920
  • 数字 4 = 2
  • 数字 5 = 836
  • 数字 6 = 381

它们都是什么意思?

我认为每个测试应该有 2 个数字:数学期望(或平均值)和标准偏差。

testing measurement rust

3
推荐指数
1
解决办法
807
查看次数

标签 统计

rust ×2

future ×1

graph ×1

measurement ×1

python ×1

select ×1

tensorflow ×1

testing ×1