我获得了一个 Google Cloud Storage 存储桶地址 ( gs://some_bucket_name
),我已被授予读取访问权限。该存储桶属于另一个项目。有什么办法可以查到bucket所属的项目名称或id吗?
假设我有以下dict对象:
test = {}
test['tree'] = ['maple', 'evergreen']
test['flower'] = ['sunflower']
test['pets'] = ['dog', 'cat']
Run Code Online (Sandbox Code Playgroud)
现在,如果我跑test['tree'] + test['flower'] + test['pets']
,我得到结果:
['maple', 'evergreen', 'sunflower', 'dog', 'cat']
Run Code Online (Sandbox Code Playgroud)
这就是我想要的.
但是,假设我不确定dict对象中有哪些键,但我知道所有值都是列表.有没有像sum(test.values())
我这样的方式来实现相同的结果?
在 Andrew Ng 的深度学习 Coursera 课程中,有一个关于触发词检测的作业(例如,不是我的:jupyter notebook)。
在作业中,他们只是提供了经过训练的模型,因为他们声称使用带有 GPU 的 4000 多个训练示例进行训练需要几个小时。
我没有使用提供的模型,而是尝试使用它们的函数创建自己的训练示例,然后从头开始训练模型。原始音频文件保持不变。有 2 个背景文件,所以我确保每个背景都有 2000 个训练示例:
n_train_per_bg = 2000
n_train = len(backgrounds)*n_train_per_bg
orig_X_train = np.empty((n_train, Tx, n_freq))
orig_Y_train = np.empty((n_train, Ty , 1))
for bg in range(len(backgrounds)):
for n in range(n_train_per_bg):
print("bg: {}, n: {}".format(bg, n))
x, y = create_training_example(backgrounds[bg], activates, negatives)
orig_X_train[bg*n_train_per_bg + n, :, :] = x.T
orig_Y_train[bg*n_train_per_bg + n, :, :] = y.T
np.save('./XY_train/orig_X_train.npy', orig_X_train)
np.save('./XY_train/orig_Y_train.npy', orig_Y_train)
Run Code Online (Sandbox Code Playgroud)
然而,跑了一个小时后,得到的结果却相当令人失望。同一个练习中后面的一个例子显示了他们正常运行的模型,当在 x 轴上的 400 标记附近检测到触发词“激活”时,显示概率峰值:
这是我的,它不仅没有检测到任何东西,而且只是扁平化!:
我所做的唯一修改是: …
我正在绘制一个默认格式显示为的图形:
我想修改它,以便每月1个月出现月份,但保留年份.我目前的尝试是这样的:
years = mdates.YearLocator()
months = mdates.MonthLocator()
monthsFmt = mdates.DateFormatter('%b-%y')
dts = s.index.to_pydatetime()
fig = plt.figure(); ax = fig.add_subplot(111)
ax.plot(dts, s)
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
Run Code Online (Sandbox Code Playgroud)
但它没有产生正确的结果:
我究竟需要如何修改它以便它像第一个一样出现但每个月都会出现月份?
我在MS SQL Server中有两个表:
dailyt
- 包含每日数据:
date val
---------------------
2014-05-22 10
2014-05-21 9.5
2014-05-20 9
2014-05-19 8
2014-05-18 7.5
etc...
Run Code Online (Sandbox Code Playgroud)
并且periodt
- 包含不定期的数据:
date val
---------------------
2014-05-21 2
2014-05-18 1
Run Code Online (Sandbox Code Playgroud)
给定一行dailyt
,我想通过添加相应的值来调整其值,periodt
最接近的日期先于或等于dailyt
行的日期.所以,输出看起来像:
addt
date val
---------------------
2014-05-22 12 <- add 2 from 2014-05-21
2014-05-21 11.5 <- add 2 from 2014-05-21
2014-05-20 10 <- add 1 from 2014-05-18
2014-05-19 9 <- add 1 from 2014-05-18
2014-05-18 8.5 <- add 1 from 2014-05-18
Run Code Online (Sandbox Code Playgroud)
我知道这样做的一种方法是连接dailyt
和 …
我正在尝试将自定义 Python 3 包安装到 PyCharm 中。该软件包附带一个 setup.py 文件。在 PyCharm 的 Project Interpreter 设置中,我尝试添加包含 setup.py 文件的本地目录(根据这些说明),但是当我重新加载要安装的可用软件包列表时,该软件包未注册。尝试添加包含 .egg 文件的目录,但也无济于事。我应该如何安装自定义软件包?有没有我可以用来代替 PyCharm 的命令行?
在 OSX Yosemite 上使用 PyCharm Pro v3.4。
我遵循LFS的说明,但有一点不同:我只遵循第 5 节 - 构建临时系统的部分内容,以便我可以构建自己的 GCC,原因是这是一台工作机器,我不这样做没有root权限。一切顺利,直到我配置时遇到错误glibc
:
configure: error:
*** These critical programs are missing or too old: as GNU ld make bison compiler
*** Check the INSTALL file for required versions.
Run Code Online (Sandbox Code Playgroud)
经过一番调查,发现我不满足 LFS 所需的条件:
/usr/bin/yacc is a symbolic link to bison or a small script that executes bison.
Run Code Online (Sandbox Code Playgroud)
结果发现没有这样的文件/usr/bin/yacc
(尽管bison
确实存在)。但是,因为我在工作中没有 root 权限,所以无法在那里创建符号链接。这里有解决方法吗?
这是我正在使用 2 条记录的示例 json 文件:
[{"Time":"2016-01-10",
"ID"
:13567,
"Content":{
"Event":"UPDATE",
"Id":{"EventID":"ABCDEFG"},
"Story":[{
"@ContentCat":"News",
"Body":"Related Meeting Memo: Engagement with target firm for potential M&A. Please be on call this weekend for news updates.",
"BodyTextType":"PLAIN_TEXT",
"DerivedId":{"Entity":[{"Id":"Amy","Score":70}, {"Id":"Jon","Score":70}]},
"DerivedTopics":{"Topics":[
{"Id":"Meeting","Score":70},
{"Id":"Performance","Score":70},
{"Id":"Engagement","Score":100},
{"Id":"Salary","Score":70},
{"Id":"Career","Score":100}]
},
"HotLevel":0,
"LanguageString":"ENGLISH",
"Metadata":{"ClassNum":50,
"Headline":"Attn: Weekend",
"WireId":2035,
"WireName":"IIS"},
"Version":"Original"}
]},
"yyyymmdd":"20160110",
"month":201601},
{"Time":"2016-01-12",
"ID":13568,
"Content":{
"Event":"DEAL",
"Id":{"EventID":"ABCDEFG2"},
"Story":[{
"@ContentCat":"Details",
"Body":"Test email contents",
"BodyTextType":"PLAIN_TEXT",
"DerivedId":{"Entity":[{"Id":"Bob","Score":100}, {"Id":"Jon","Score":70}, {"Id":"Jack","Score":60}]},
"DerivedTopics":{"Topics":[
{"Id":"Meeting","Score":70},
{"Id":"Engagement","Score":100},
{"Id":"Salary","Score":70},
{"Id":"Career","Score":100}]
},
"HotLevel":0,
"LanguageString":"ENGLISH",
"Metadata":{"ClassNum":70,
"Headline":"Attn: Weekend",
"WireId":2037,
"WireName":"IIS"}, …
Run Code Online (Sandbox Code Playgroud) 我有一个csv文件,其中包含一些带有美元符号的单元格(例如$46.5
)。我强迫所有类型都numpy.float64
在函数中pandas.read_csv()
。它抱怨ValueError: could not convert string to float: $46.5
。有没有办法干净地处理这个问题?
python ×5
date ×2
pandas ×2
python-3.x ×2
dictionary ×1
gcc ×1
glibc ×1
installation ×1
json ×1
keras ×1
linux ×1
list ×1
matplotlib ×1
normalize ×1
numpy ×1
package ×1
pycharm ×1
rnn ×1
sql ×1
sql-server ×1
t-sql ×1
tensorflow ×1