我在 中使用该autograd工具PyTorch,并且发现自己需要通过整数索引访问一维张量中的值。像这样的东西:
def basic_fun(x_cloned):
res = []
for i in range(len(x)):
res.append(x_cloned[i] * x_cloned[i])
print(res)
return Variable(torch.FloatTensor(res))
def get_grad(inp, grad_var):
A = basic_fun(inp)
A.backward()
return grad_var.grad
x = Variable(torch.FloatTensor([1, 2, 3, 4, 5]), requires_grad=True)
x_cloned = x.clone()
print(get_grad(x_cloned, x))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
[tensor(1., grad_fn=<ThMulBackward>), tensor(4., grad_fn=<ThMulBackward>), tensor(9., grad_fn=<ThMulBackward>), tensor(16., grad_fn=<ThMulBackward>), tensor(25., grad_fn=<ThMulBackward>)]
Traceback (most recent call last):
File "/home/mhy/projects/pytorch-optim/predict.py", line 74, in <module>
print(get_grad(x_cloned, x))
File "/home/mhy/projects/pytorch-optim/predict.py", line 68, in get_grad
A.backward()
File "/home/mhy/.local/lib/python3.5/site-packages/torch/tensor.py", line 93, in backward …Run Code Online (Sandbox Code Playgroud) Run Code Online (Sandbox Code Playgroud)sync sync all resources from state file (repos, releases and chart deps) apply apply all resources from state file only when there are changes
同步
Run Code Online (Sandbox Code Playgroud)The helmfile sync sub-command sync your cluster state as described in your helmfile ... Under the covers, Helmfile executes helm upgrade --install for each release declared in the manifest, by optionally decrypting secrets to be consumed as helm chart values. It also updates specified chart repositories and updates the dependencies of any referenced local charts. …
我正在开发一个仪表板,它接收所有 Alertmanager 读数并处理它们。我在请求负载中寻找一个唯一的字段,以在我的数据库中创建一个唯一的外部警报 ID。请求负载看起来像这样:
{
"status": "firing",
"labels": {
"alertname": "",
"app": "",
"cluster": "",
"deployed_location": "",
"instance": "",
"job": "",
"kubernetes_namespace": "",
"kubernetes_pod_name": "",
"pod_template_hash": "",
"release": "",
"replica": "",
"severity": ""
},
"annotations": {
"description": "",
"summary": ""
},
"startsAt": "",
"endsAt": "",
"generatorURL": "",
"fingerprint": ""
}
Run Code Online (Sandbox Code Playgroud)
我第一次使用该generatorURL字段,但后来意识到许多不同的警报具有相同的值generatorURL。我一直在努力fingerprint,情况好多了。但是,我遇到过 2 到 15 个警报具有相同fingerprint.
我想知道:
fingerprint,则不要在我的数据库中创建事件fingerprint已使用。我还担心,如果我设置unique=True警报模型,一些具有相同指纹的新警报将会被错过......我正在尝试使用 Wix/Detox 来测试我的 react-native 应用程序(iOS 版本)。我已成功遵循https://github.com/wix/detox/blob/master/docs/Introduction.GettingStarted.md 上的说明(直到“排毒构建”)
但是,在我的项目目录中运行“detox build”时,出现以下错误:
** BUILD FAILED **
The following commands produced analyzer issues:
Analyze RNFIRMessaging.m
(1 command with analyzer issues)
The following build commands failed:
Ld build/Build/Products/Debug-iphonesimulator/<myAppName>.app/<myAppName> normal x86_64
(1 failure)
child_process.js:524
throw err;
^
Error: Command failed: xcodebuild -project ios/<myAppName>.xcodeproj -scheme <myAppName> -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build
at checkExecSyncError (child_process.js:481:13)
at Object.execSync (child_process.js:521:13)
at Object.<anonymous> (/Users/<myUserName>/Documents/react-native-projects/<myAppName>/node_modules/detox/local-cli/detox-build.js:26:6)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用排毒测试我的react-native应用程序,等待文本输入可见并在其中键入文本.我的规范JS文件看起来像这样:
describe('FiestTest', () => {
beforeEach(async () => {
await device.reloadReactNative()
})
it('Login to a test account', async () => {
// LoginPage: entering phone number moving to next page
await expect(element(by.id('LoginPage-phoneInput'))).toBeVisible()
await element(by.id('LoginPage-phoneInput')).typeText('<someNumber>')
})
})
Run Code Online (Sandbox Code Playgroud)
而我得到的错误是:
FiestTest
1) Enter phone number and tap on button
0 passing (15s)
1 failing
1) FiestTest Enter phone number and tap on button:
Error: An action failed. Please refer to the error trace below.
Exception with Action: {
"Action Name" : …Run Code Online (Sandbox Code Playgroud) PyTorch按照官方网站的指示,要在Ubuntu上安装,我做了pip3 install torch torchvision,并且可以PyTorch使用该python3.5命令运行。
但是,当我运行时Jupyter Notebook(我只是Jupyter Notebook在终端中运行并使用Chrome访问我的笔记本),它无法识别该程序包,并朝ModuleNotFoundError: No module named 'torch'我扔去。
另一个奇怪的事情是,PyTorch似乎只安装了该设备,Python 3.5而没有安装,Python 3.6原因是:
? ~ python3.5 -c "import torch; print(torch.__version__)"
0.4.1
? ~ python3.6 -c "import torch; print(torch.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
? ~
Run Code Online (Sandbox Code Playgroud)
因此,我猜这Jupyter Notebook没有使用Python 3.5。
这是我python在终端中键入并按TAB以下命令时的结果: …
我正在尝试使用Alpine图像来处理一些Postgres数据库创建/准备工作。在容器内,我正在运行以下命令:
createdb -e -O ${DB_USER} ${DB_NAME}
psql -e -d ${DB_NAME} -c "CREATE EXTENSION postgis;"
Run Code Online (Sandbox Code Playgroud)
第一行工作正常,但第二行不行。
我已经用两个 docker 构建尝试过这个:
FROM alpine:3.6
RUN apk add -U postgresql
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
Run Code Online (Sandbox Code Playgroud)
这张图片给了我以下错误:
CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)
我没有尝试PostGIS直接安装,因为本论坛中有人坚持认为apk add -U postgresql裸Alpine图像就足够了。
FROM postgres:9.6.4-alpine
RUN apk add -U postgresql
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN …Run Code Online (Sandbox Code Playgroud) 好的,所以任务看起来很简单!使用Alpine图像(因为它轻量级且安全)来执行一些PostgreSQL数据库创建/迁移。我使用的是以下Dockerfile使用的代码在这里:
FROM alpine:latest
RUN apk add -U postgresql
# install PostGIS
ENV POSTGIS_VERSION 2.5.2
ENV POSTGIS_SHA256 225aeaece00a1a6a9af15526af81bef2af27f4c198de820af1367a792ee1d1a9
RUN set -ex \
\
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
\
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz" \
&& echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c - \
&& mkdir -p /usr/src/postgis \
&& tar \
--extract \
--file postgis.tar.gz \
--directory /usr/src/postgis \
--strip-components 1 \
&& rm …Run Code Online (Sandbox Code Playgroud) 是否有Kubectl命令可以找出有关 a 的以下信息Pod?
安装的Linux发行版
操作系统版本
假设您确实没有关于创建aDeployment或 a的图像的大量信息......Pod
alpine-linux ×2
detox ×2
docker ×2
ios ×2
javascript ×2
kubernetes ×2
postgis ×2
postgresql ×2
python ×2
react-native ×2
anaconda ×1
autograd ×1
conda ×1
helmfile ×1
iphone ×1
kubectl ×1
pip ×1
pytorch ×1
testing ×1