小编Enn*_*our的帖子

使用 Google RE2 同时匹配多个正则表达式

我尝试使用 Google 的 RE2 库快速匹配许多(500 多个)正则表达式,因为我希望获得与本白皮书类似的结果。我想使用第 13 页的 RE2-m。

从我在网上看到的情况来看,Set 接口是可行的方法,尽管我不确定从哪里开始——我还没有找到在线使用 set 接口的 Google RE2 教程。有人可以指出我正确的方向吗?

c++ re2

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

让 Tensorflow 自动检测和使用 XLA GPU

我有一个无法被 tensorflow 自动检测到的 XLA GPU,但我能够对其执行计算。我想要的结果:结果print(tf.test.is_gpu_available())是“真”。

这是我正在运行的代码:

#!/usr/bin/python3
import tensorflow as tf

print("Is a GPU Available for TensorFlow?")
print(tf.test.is_gpu_available())

with tf.device('/device:XLA_GPU:0'):
  a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
  b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
  c = tf.matmul(a, b)

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

print("Result of Running the Session")
print(sess.run(c))
Run Code Online (Sandbox Code Playgroud)

这是相关的输出:

Is a GPU Available for TensorFlow?
False
Result of Running the Session
[[22. 28.]
 [49. 64.]]
Device mapping:
/job:localhost/replica:0/task:0/device:XLA_GPU:0 -> device: XLA_GPU …
Run Code Online (Sandbox Code Playgroud)

tensorflow tensorflow-xla

5
推荐指数
0
解决办法
1695
查看次数

带有列表的 pandas 数据框中的唯一项目

我正在尝试从 pandas 数据框中删除所有列,其中该列中的唯一项少于 10 个。但是,我的一些数据是列表,我收到错误unhashable type: 'list'。这是有道理的,因为 pandas 与哈希图进行比较。

我当前的代码是

for i in df.columns:
    if len(df[i].unique()) < 10:
        df.drop(i, 1)
Run Code Online (Sandbox Code Playgroud)

在我到达列表对象之前,它工作得很好。就我的目的而言, list1 和 list2 不是唯一的。[1, 2]并且[2, 1]不是唯一的,尽管[1, 2] == [2, 1]是 False 。

我应该如何执行此操作?分隔列表没有意义,而且我无法显式键入列,因为我有 1400 个列。

提前谢谢了!

python dataframe pandas

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

std::optional 不编译

此代码不能使用命令 g++ -std=c++17 main.cpp 编译

#include <iostream>
#include <experimental/optional>

int main()
{
    std::optional<int> x;
    std::cout << "Hello World";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

错误如下:

  1. 错误:“可选”不是“标准”的成员
  2. 错误:'int' 之前的预期主表达式

有没有办法让这段代码编译?

c++ std stdoptional

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

标签 统计

c++ ×2

dataframe ×1

pandas ×1

python ×1

re2 ×1

std ×1

stdoptional ×1

tensorflow ×1

tensorflow-xla ×1