由于gdb现在在Mac上工作变得繁重(至少我觉得我正在与Apple抗争),我已经开始玩lldb了.
是否有一个等效的模式,gdb -tui它显示了一个漂亮的,持久的源视图,以及从命令行运行lldb独立时你在哪里?显然,在Xcode中,有这样的显示器,但我最终将我的大部分代码部署到Linux盒子,并且更愿意在两个平台上使用相同的开发环境(即vim,Makefile,autotools等).
我正在阅读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)
但这感觉很难看.这样做有更好的方法吗?
我正在尝试使用 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) 我无法使用我认为应该工作的使用声明:
#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)