小编Gab*_*due的帖子

独立的lldb是否有"TUI"模式?

由于gdb现在在Mac上工作变得繁重(至少我觉得我正在与Apple抗争),我已经开始玩lldb了.

是否有一个等效的模式,gdb -tui它显示了一个漂亮的,持久的源视图,以及从命令行运行lldb独立时你在哪里?显然,在Xcode中,有这样的显示器,但我最终将我的大部分代码部署到Linux盒子,并且更愿意在两个平台上使用相同的开发环境(即vim,Makefile,autotools等).

lldb

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

如何在jq中很好地删除空数组

我正在阅读O'Reilly新的"命令行数据科学"并使用jq遇到麻烦.我有一些JSON(从NYTimes Articles API返回)我用jq解析如下:

jq -c \
'[.response.docs[] | {date: .pub_date, type: .document_type, title: .headline.main }]' \
< myjsonfile.json
Run Code Online (Sandbox Code Playgroud)

所以,我正在寻找"响应":"docs"(这是一个数组),然后将该数组中的每个项目与"pub_type"等匹配,重命名,等等.这很好用,但最后会添加一个空数组:

[{"date":"2009-01-02T00:00:00Z","type":"article","title":"SPARE TIMES: AROUND TOWN"},  
{"date":"2009-01-02T00:00:00Z","type":"article","title":"Catskill Home Prices: How Low Will They Go?"},
{"date":"2009-01-01T00:00:00Z","type":"article","title":"Ominous Cutbacks At Chanel"}]
[] 
Run Code Online (Sandbox Code Playgroud)

我如何摆脱空阵列?我现在的解决方案是将输出管道输回到jq,但这感觉真的不是最理想的.这样可行:

jq -c \
'[.response.docs[] | {date: .pub_date, type: .document_type, title: .headline.main }]' | \
< myjsonfile.json | 
jq 'if length > 0 then . else empty end'
Run Code Online (Sandbox Code Playgroud)

但这感觉很难看.这样做有更好的方法吗?

json jq

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

具有可变批量大小的 TensorFlow DataSet `from_generator`

我正在尝试使用 TensorFlow Dataset API 读取 HDF5 文件,使用该from_generator方法。除非批量大小没有均匀地划分为事件数量,否则一切正常。我不太明白如何使用 API 进行灵活的批处理。

如果事情没有平均分配,你会得到如下错误:

2018-08-31 13:47:34.274303: W tensorflow/core/framework/op_kernel.cc:1263] Invalid argument: ValueError: `generator` yielded an element of shape (1, 28, 28, 1) where an element of shape (11, 28, 28, 1) was expected.
Traceback (most recent call last):

  File "/Users/perdue/miniconda3/envs/py3a/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 206, in __call__
    ret = func(*args)

  File "/Users/perdue/miniconda3/envs/py3a/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 452, in generator_py_func
    "of shape %s was expected." % (ret_array.shape, expected_shape))

ValueError: `generator` yielded an element of shape (1, 28, 28, 1) where …
Run Code Online (Sandbox Code Playgroud)

python tensorflow tensorflow-datasets

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

在C++ 11中为iterator输入alias/using声明

我无法使用我认为应该工作的使用声明:

#include <iostream>
#include <vector>
using namespace std;

template<typename C, typename V>
vector<typename C::iterator> find_all1(C& c, V v)
{
  vector<typename C::iterator> res;
  for (auto p = c.begin(); p!=c.end(); ++p) {
    if (*p == v)
      res.push_back(p);
  }
  return res;
}

template<typename T>
using Iterator<T> = typename T::iterator;

template <typename C, typename V>
vector<Iterator<C>> find_all2(C& c, V v)
{
  vector<Iterator<C>> res;
  for (auto p = c.begin(); p != c.end(); ++p) {
    if (*p == v)
      res.push_back(p);
  }
  return res;
}

int main(int …
Run Code Online (Sandbox Code Playgroud)

alias templates using c++11 template-aliases

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