小编Eva*_*urg的帖子

什么`android.accounts.Account.type`引用?

在Google Play Developer控制台中,我在启动前测试中收到警告,提到:

java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.accounts.Account.type' on a null object reference

该应用程序永远不会崩溃并且测试成功,但警告仍然存在于测试的详细信息中.什么是android.accounts.Account如何以及如何确保它没有问题?

java testing android

11
推荐指数
1
解决办法
1002
查看次数

TypeError:无法在Seq2Seq中pickle _thread.lock对象

我在Tensorflow模型中使用存储桶时遇到问题.当我运行它时buckets = [(100, 100)],它工作正常.当我用buckets = [(100, 100), (200, 200)]它运行它根本不起作用(底部的堆栈跟踪).

有趣的是,运行Tensorflow的Seq2Seq教程会产生相同类型的问题,几乎相同的堆栈跟踪.出于测试目的,此处链接到存储库.

我不确定问题是什么,但是有多个桶总是会触发它.

这段代码不能单独运行,但这是崩溃的功能 - 记住buckets从更改[(100, 100)][(100, 100), (200, 200)]触发崩溃.

class MySeq2Seq(object):
    def __init__(self, source_vocab_size, target_vocab_size, buckets, size, num_layers, batch_size, learning_rate):
        self.source_vocab_size = source_vocab_size
        self.target_vocab_size = target_vocab_size
        self.buckets = buckets
        self.batch_size = batch_size

        cell = single_cell = tf.nn.rnn_cell.GRUCell(size)
        if num_layers > 1:
            cell = tf.nn.rnn_cell.MultiRNNCell([single_cell] * num_layers)

        # The seq2seq function: we use embedding for the input and attention
        def …
Run Code Online (Sandbox Code Playgroud)

nlp python-3.x lstm tensorflow sequence-to-sequence

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

快速检查大型数据库的编辑距离相似性

我有一个350,000字符串数据库,平均长度约为500.字符串不是由单词组成的,它们是基本上随机的字符组合.

我需要确保没有两个字符串太相似,其中相似性定义为编辑距离除以字符串的平均长度.划分是因为较小的字符串更容易接受较小的编辑距离.如果出于性能原因使用不同的度量标准,则可以正常运行,但编辑距离是首选的基准度量标准.

天真地,我们用运行时计算编辑距离,两个字符串的长度O(a*b)在哪里a,b.我们为所有n^2对执行此操作,这使得整体运行时间O(n^2*a*b)明显过大n=350,000, a,b=500.

数据库采用从csv文件读取的Python列表的形式.如果可能的话,我想以Pythonic的方式处理它.

怎么加速呢?我不确定天真算法需要多长时间才能完成(大约几周)但理想情况下应该花不到一天的时间才能运行.

python edit-distance similarity python-3.x

9
推荐指数
1
解决办法
707
查看次数

获取Tensorflow中数据集的长度

source_dataset = tf.data.TextLineDataset('primary.csv')
target_dataset = tf.data.TextLineDataset('secondary.csv')
dataset = tf.data.Dataset.zip((source_dataset, target_dataset))
dataset = dataset.shard(10000, 0)
dataset = dataset.map(lambda source, target: (tf.string_to_number(tf.string_split([source], delimiter=',').values, tf.int32),
                                              tf.string_to_number(tf.string_split([target], delimiter=',').values, tf.int32)))
dataset = dataset.map(lambda source, target: (source, tf.concat(([start_token], target), axis=0), tf.concat((target, [end_token]), axis=0)))
dataset = dataset.map(lambda source, target_in, target_out: (source, tf.size(source), target_in, target_out, tf.size(target_in)))

dataset = dataset.shuffle(NUM_SAMPLES)  #This is the important line of code
Run Code Online (Sandbox Code Playgroud)

我想完全整理我的整个数据集,但是shuffle()需要抽取大量样本,并且tf.Size()无法使用tf.data.Dataset.

我怎么能正常洗牌?

dataset python-3.x tensorflow

7
推荐指数
1
解决办法
5498
查看次数

第一批后的Tensorflow ResourceExhaustedError

摘要和测试用例

核心问题是Tensorflow会抛出一个不是第一个批次的OOM分配,正如我所料.因此,我认为存在内存泄漏,因为在每批之后显然没有释放所有内存.

num_units: 50, batch_size: 1000; fails OOM (gpu) before 1st batch as expected
num_units: 50, batch_size: 800, fails OOM (gpu) before 1st batch as expected
num_units: 50, batch_size: 750; fails OOM (gpu) after 10th batch (???)
num_units: 50, batch_size: 500; fails OOM (gpu) after 90th batch (???)
num_units: 50, batch_size: 300; fails OOM (gpu) after 540th batch (???)
num_units: 50, batch_size: 200; computer freezes after around 900 batches with 100% ram use
num_units: 50, batch_size: 100; passes 1 epoch …
Run Code Online (Sandbox Code Playgroud)

python python-3.x tensorflow neural-mt

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

如何将Boost与Eclipse结合使用?

我在安装用于Eclipse C ++(编译器MinGW)的Boost时遇到很多麻烦。

我首先尝试在下载zip文件https://sourceforge.net/projects/boost/files/boost/1.61.0/。下载后,我将其带到第二个驱动器,将文件解压缩到那里,在其中cd,然后运行./bootstrap.bat gcc,似乎可以成功运行。

然后,我运行b2 install --prefix="D:\boostfiles" toolset=gcc了大约30分钟的时间来创建许多以bin.v2和结尾的文件rst

但是,#include <boost/asio.hpp>仍然给出错误。文件应该在什么地方?

作为参考,我的文件结构包括原boost_1_61_0提取的文件夹,该升压被安装到所谓的一个文件夹boostfiles和文件夹,名为PFiles既包括eclipseMinGW

请保持简单,我很新。谢谢!

c++ eclipse boost mingw

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

如何从函数内部修改范围变量?

这是在C++(Eclipse Mars,如果重要,编译器MinGW).假设我想将一个字符串拆分为一个字符上的两个字符串,并使用一个函数:

int strParse(const string& a) {
    // parse line read input
    int b = a.find("-");
    firstsplit = a.substr(0, b);
    secsplit = a.substr(b + 1);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是我想定义firstsplitsecsplit不是全局变量,但是在main()它们被使用的范围内.当它们在那里被定义时,它们不能在函数中使用,但我需要函数来定义它们以供部分使用main.

c++ function

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