小编use*_*360的帖子

从 Python 中调用 Google Cloud Function

我正在尝试使用以下命令从 Python 中调用 Google Cloud 函数:

import requests
url = "MY_CLOUD_FUNCTON_URL"
data = {'name': 'example'}
response = requests.post(url, data = data)
Run Code Online (Sandbox Code Playgroud)

但我得到了错误:Your client does not have permission to get URL MY_CLOUD_FUNCTON from this server

有谁知道我怎样才能避免这个错误?我假设我应该以某种方式将凭据作为请求的一部分传递?

另请注意,如果我尝试从命令行通过 gcloud 调用该函数(如下所示),那么它可以工作,但我想在 python 中执行此操作

gcloud functions call MY_CLOUD_FUNCTON --data '{"name": "example"}' 
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激!

python python-requests google-cloud-platform google-cloud-functions

14
推荐指数
2
解决办法
9937
查看次数

拥抱脸的变形金刚在哪里保存模型?

运行下面的代码下载一个模型 - 有谁知道它下载到哪个文件夹?

!pip install -q transformers
from transformers import pipeline
model = pipeline('fill-mask')
Run Code Online (Sandbox Code Playgroud)

huggingface-transformers

14
推荐指数
4
解决办法
5664
查看次数

在 github 操作中使用 psql

我正在尝试在 github 操作中使用 psql,但看到以下错误:

psql: error: could not connect to server: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

我的 github 操作 yml 文件如下所示(run_all_tests.sh 文件仅调用尝试运行命令 psql 的子进程)。有谁知道为什么会发生这种情况?

name: Python application

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  build:
    runs-on: ubuntu-latest

    # Service containers to run with `container-job`
    services:
      # Label used to access the service container
      postgres:
        # Docker Hub image
        image: postgres …
Run Code Online (Sandbox Code Playgroud)

postgresql github psql github-actions

8
推荐指数
1
解决办法
9855
查看次数

如何在tensorflow 2.0中使用层列表?

下面的代码向我抛出错误“AttributeError:无法设置属性”。我认为这是因为我试图将 TensorFlow 层放入普通列表中。

有谁知道我如何解决这个问题并能够创建图层列表?我不想使用顺序,因为它不太灵活。

在 PyTorch 中,他们有 ModuleLists,您可以使用它来代替列表,我可以使用 TensorFlow 中的等效项吗?

!pip install tensorflow-gpu==2.0.0-alpha0
import tensorflow as tf
from tensorflow.keras.layers import Dense, Flatten, Conv2D
from tensorflow.keras import Model

class MyModel(Model):
  def __init__(self):
    super(MyModel, self).__init__()
    self.layers = self.create_layers()

  def create_layers(self):    
    layers = [Conv2D(32, 3, activation='relu'), Flatten(), 
              Dense(128, activation='relu'), Dense(10, activation='softmax')]
    return layers

  def call(self, x):
    for layer in self.layers:
      x = layer(x)
    return x

model = MyModel()
Run Code Online (Sandbox Code Playgroud)

完整的问题

tensorflow tensorflow2.0

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

使用huggingface fill-mask管道获得超过5条建议

下面让我得到 5 个关于蒙面令牌的建议,但我想得到 10 个建议 - 有谁知道这是否可以通过拥抱脸来实现?

!pip install -q transformers
from __future__ import print_function
import ipywidgets as widgets
from transformers import pipeline

nlp_fill = pipeline('fill-mask')
nlp_fill("I am going to guess <mask> in this sentence")
Run Code Online (Sandbox Code Playgroud)

python nlp neural-network huggingface-transformers

6
推荐指数
2
解决办法
6502
查看次数

从huggingface特征提取管道中获取句子嵌入

如何从 Huggingface 的特征提取管道中获取整个句子的嵌入?

我了解如何获取每个标记的特征(如下),但如何获取整个句子的总体特征?

feature_extraction = pipeline('feature-extraction', model="distilroberta-base", tokenizer="distilroberta-base")
features = feature_extraction("i am sentence")
Run Code Online (Sandbox Code Playgroud)

nlp machine-learning spacy-transformers huggingface-transformers

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

将具有自定义转发功能的模型上传到 Huggingface 模型中心?

是否可以将具有自定义转发功能的模型上传到 Huggingface 模型中心?

如果您的模型是正常形式,我可以看到如何执行此操作,但看不到如何自定义转发函数并执行此操作?

huggingface-transformers

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