小编mhy*_*efi的帖子

PyTorch autograd -- 只能为标量输出隐式创建 grad

我在 中使用该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)

python pytorch autograd

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

helmfile 同步与 helmfile 应用

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. …
Run Code Online (Sandbox Code Playgroud)

kubernetes kubernetes-helm helmfile

9
推荐指数
2
解决办法
4632
查看次数

Alertmanager中的指纹字段是唯一的吗?

我正在开发一个仪表板,它接收所有 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.

我想知道:

  1. Alertmanager 请求中真的没有唯一字段吗?
  2. 这是 Alertmanager 逻辑(或我的警报)的本质,即使用相同的警报创建了许多警报,我应该只处理它并在我这边处理它,即如果给定的是fingerprint,则不要在我的数据库中创建事件fingerprint已使用。我还担心,如果我设置unique=True警报模型,一些具有相同指纹的新警报将会被错过......

fingerprinting prometheus-alertmanager

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

排毒问题:BUILD FAILED Ld build/Build/Products/Debug-iphonesimulator

我正在尝试使用 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)

javascript iphone ios react-native detox

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

排毒_无法键入字符串,因为键盘未显示在屏幕上

我正在尝试使用排毒测试我的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)

javascript testing ios react-native detox

5
推荐指数
2
解决办法
1960
查看次数

Jupyter Notebook无法识别“进口火炬”

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以下命令时的结果: …

python pip anaconda conda jupyter-notebook

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

无法在高山图像上使用 PostGIS

我正在尝试使用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 构建尝试过这个:

  1. 以下 Dockerfile:
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 postgresqlAlpine图像就足够了。

  1. 以下 Dockerfile:
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)

postgresql postgis docker alpine-linux

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

错误:在 Alpine Docker 映像上安装 PostGIS 时出现无法满足的约束

好的,所以任务看起来很简单!使用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)

postgresql postgis docker alpine-linux

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

Kubectl 命令找出 Linux 发行版和版本

是否有Kubectl命令可以找出有关 a 的以下信息Pod

  1. 安装的Linux发行版

  2. 操作系统版本

假设您确实没有关于创建aDeployment或 a的图像的大量信息......Pod

kubernetes kubectl

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