小编ted*_*ddy的帖子

由于在Mac OS X上brew install gcc之后缺少fortran编译器,仍然无法安装scipy

我已阅读并按照此答案安装scipy/numpy/theano.但是,在brew install gcc之后,它仍然失败了同样的错误,即缺少Fortran编译器.虽然HomeBrew安装了gcc-4.8,但它没有安装任何gfortran或g95命令.我认为gfortran可能只是gcc 的同义词,然后我创建了一个符号链接

$ cd /usr/local/bin
$ ln -s gcc-4.8 gfortran
$ pip install scipy
Run Code Online (Sandbox Code Playgroud)

然后它检测到gfortran命令,但仍抱怨没有Fortran编译器

customize Gnu95FCompiler
Found executable /usr/local/bin/gfortran
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize G95FCompiler
Could not …
Run Code Online (Sandbox Code Playgroud)

python macos homebrew fortran numpy

36
推荐指数
2
解决办法
3万
查看次数

如何从共享变量支持的theano tensor变量中获取值?

我有一个通过转换共享变量创建的theano tensor变量.如何提取原始值或已转换值?(我需要这样,所以我不必携带原始的共享/ numpy值.)

>>> x = theano.shared(numpy.asarray([1, 2, 3], dtype='float'))
>>> y = theano.tensor.cast(x, 'int32')
>>> y.get_value(borrow=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'TensorVariable' object has no attribute 'get_value'
# whereas I can do this against the original shared variable
>>> x.get_value(borrow=True)
array([ 1.,  2.,  3.])
Run Code Online (Sandbox Code Playgroud)

python numpy scipy theano

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

如何将InputStream复制到AsynchronousFileChannel

我想从(Tomcat servlet)InputStream中读取并使用AsynchronousFileChannel异步地将(大)内容复制到文件中.我可以使用常规的FileChannel来完成它并阅读有关丢失的transferTo.但是,如果我使用Java 7 AsyncFileChannel,我总是得到BufferOverflowException.

    try (AsynchronousFileChannel output = AsynchronousFileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
         output.lock(); // need to lock, this is one key reason to use channel

        ReadableByteChannel input = Channels.newChannel(inputStream); // servlet InputStream
        ByteBuffer buf = ByteBuffer.allocate(4096);
        int position = 0;
        int count;
        Future<Integer> lastWrite = null;
        while ((count = input.read(buf)) >= 0 || buf.position() > 0) {
            logger.info("read {} bytes", count);
            buf.flip();
            output.write(buf, position);
            if (count > 0) position += count;
            buf.compact();
        }
        if (lastWrite != null) …
Run Code Online (Sandbox Code Playgroud)

java asynchronous nio

6
推荐指数
1
解决办法
1158
查看次数

使用类型信息优雅地忽略Jackson JSON反序列化中的未知类?

使用jackson JSON库,我能够生成带有类型字段信息的JSON并将其读回.但是,我的JSON对象的某些客户端可能无法访问特定的类.我希望他们将JSON属性序列化为Map.这似乎不起作用,如下面的代码所示.怎么做这招?

static class Foo {
    @JsonProperty
    private String x;
    @JsonProperty
    @JsonTypeInfo(use= JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
    private Object o;

    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }

    public Object getO() {
        return o;
    }

    public void setO(Object o) {
        this.o = o;
    }
}

@Test
public void testJacksonTypedSerialization() throws Exception {
    Foo foo = new Foo();
    foo.setX("hello world!");
    Foo foo2 = new Foo();
    foo2.setX("inner");
    foo.setO(foo2);

    ObjectMapper mapper = new ObjectMapper();

    String str …
Run Code Online (Sandbox Code Playgroud)

java serialization json jackson

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

TensorFlow:`tf.data.Dataset.from_generator()`不适用于Python 3.x上的字符串

我需要迭代大量的图像文件并将数据提供给tensorflow.我Dataset通过生成器函数创建了一个返回,它将文件路径名称生成为字符串,然后使用将字符串路径转换为图像数据map.但它失败了,因为生成字符串值不起作用,如下所示.有没有修复或解决这个问题?

2017-12-07 15:29:05.820708: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
producing data/miniImagenet/val/n01855672/n0185567200001000.jpg
2017-12-07 15:29:06.009141: W tensorflow/core/framework/op_kernel.cc:1192] Unimplemented: Unsupported object type str
2017-12-07 15:29:06.009215: W tensorflow/core/framework/op_kernel.cc:1192] Unimplemented: Unsupported object type str
     [[Node: PyFunc = PyFunc[Tin=[DT_INT64], Tout=[DT_STRING], token="pyfunc_1"](arg0)]]
Traceback (most recent call last):
  File "/Users/me/.tox/tf2/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
    return fn(*args)
  File "/Users/me/.tox/tf2/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
    status, run_metadata)
  File "/Users/me/.tox/tf2/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__ …
Run Code Online (Sandbox Code Playgroud)

tensorflow tensorflow-datasets

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

如何使用tensorflow.Estimator进行强化学习

tensorflow.Estimator似乎与监督学习有关,但即使模型或培训只需要进行小的改动,似乎很难采用其他任务.例如,在强化学习中,我需要提供一个奖励值,而这个值不属于features.

tensorflow tensorflow-estimator

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

让 Amazon S3 在丢失对象请求时重定向到我的终端节点?

我们使用 S3 来在线存储文件。为了降低成本,可以使用提前已知的路径按需生成其中的许多文件。

是否可以让 S3 存储桶将丢失的对象请求重定向到我预先配置的端点(然后可以按需生成和提供文件)?

例如,对http://bucket1.s3.amazonaws.com/path2/file3.jpg的请求会临时重定向 (307) 到http://mydomain.com/missing_s3_obj/bucket1/path2/file3.jpg

redirect http amazon-s3

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

RubyMine/IDEA ruby​​调试器无法在bundler模​​式下加载linecache gem

在捆绑器中启动调试器(在运行目标的捆绑器选项卡中选中"在捆绑包上下文中运行脚本"选项)在IDEA 13(以及早期版本,例如11)Ruby,我总是得到

/Users/me/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide --disable-int-handler --port 58100 --dispatcher-port 58101 -- /Users/me/railproj/script/spec --format specdoc spec/**/any_ruby_spec.rb
/Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-base-0.10.5.rc9/lib/ruby-debug-base.rb:3:in `require': no such file to load -- linecache (LoadError)
    from /Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/ruby-debug-base-0.10.5.rc9/lib/ruby-debug-base.rb:3
    from /Users/me/Library/Application Support/IntelliJIdea13/ruby/rb/gems/debug_preloader.rb:2:in `require'
    from /Users/me/Library/Application Support/IntelliJIdea13/ruby/rb/gems/debug_preloader.rb:2
Run Code Online (Sandbox Code Playgroud)

linecache gem正确安装

$ gem which linecache
/Users/me/.rvm/gems/ree-1.8.7-2012.02/gems/linecache-0.46/lib/linecache.rb
Run Code Online (Sandbox Code Playgroud)

将行缓存放在Gemfile中根本没有用.

但是为没有bundler的同一个运行目标启动调试器(取消选中"在bundle上下文中运行脚本")可以工作.当然,人们可以通过捆绑上下文轻松地获得宝石冲突.

怎么解决这个问题?

ruby gem ruby-on-rails rubymine bundler

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

在 nginx 位置指令中添加响应头

我尝试将响应标头添加到仅提供一个位置路径,并且 nginx 配置如下所示

server {
    ...
    add_header x-test test;
    location /my.img {
        rewrite ^/my.img$ /119.img;
        add_header x-amz-meta-sig 1234567890abcdef;
    }
}
Run Code Online (Sandbox Code Playgroud)

但只有顶级标头(x-test)有效,位置指令中的标头不会显示,如图所示

$ curl -v -o /tmp/test.img 'https://www.example.com/my.img'
< HTTP/1.1 200 OK
< Server: nginx/1.9.3 (Ubuntu)
< Date: Sun, 14 May 2017 23:58:08 GMT
< Content-Type: application/octet-stream
< Content-Length: 251656
< Last-Modified: Fri, 03 Mar 2017 04:57:47 GMT
< Connection: keep-alive
< ETag: "58b8f7cb-3d708"
< x-test: test
< Accept-Ranges: bytes
< 
{ [16104 bytes data]
Run Code Online (Sandbox Code Playgroud)

如何仅针对所服务的特定文件发回自定义 headrr。

nginx nginx-location

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

在Android应用中通过WebView在WebRTC中没有音频

我开发了一个简单的Android应用程序,它包装WebView以连接到apprtc.appspot.com.WebRTC会话成功建立,视频流显示在应用程序和对等设备(Mac上的Chrome浏览器)中,可以在应用程序上听到音频,但Mac不会收到任何音频.Chrome:// Mac上的Chrome浏览器上的webrtc-internals显示没有错误.从Android设备中的Chrome到Mac中的Chrome的WebRTC可以很好地处理音频.我还在应用程序中编写了一个测试活动,以使用成功捕获和播放音频的MediaRecorder和MediaPlayer.

我的权限设置看起来像

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.audio.low_latency" />
<uses-feature android:name="android.hardware.audio.pro" />
<uses-feature android:name="android.hardware.microphone" android:required="true"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.front" android:required="true" />
Run Code Online (Sandbox Code Playgroud)

应用代码看起来像

    int permission;

    permission = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
    if (permission != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.RECORD_AUDIO)) {
            // Show an expanation to the user *asynchronously* -- don't block
        } else {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.RECORD_AUDIO},
                    MY_PERMISSIONS_REQUEST_AUDIO);
        }
    }
    // ... similar …
Run Code Online (Sandbox Code Playgroud)

audio android audio-streaming webview

3
推荐指数
2
解决办法
2947
查看次数