小编Vla*_*-HC的帖子

为什么导入“from tensorflow.train import Feature”不起作用

这可能完全是菜鸟问题,与 python 模块导入有关,但我不明白为什么以下内容有效:

> import tensorflow as tf
> f = tf.train.Feature()

> from tensorflow import train
> f = train.Feature()
Run Code Online (Sandbox Code Playgroud)

但是下面的语句会导致错误:

> from tensorflow.train import Feature
ModuleNotFoundError: No module named 'tensorflow.train'
Run Code Online (Sandbox Code Playgroud)

请有人解释一下为什么它不能这样工作?我的目标是在代码中使用更短的符号,如下所示:

> example = Example(
    features=Features(feature={
        'x1': Feature(float_list=FloatList(value=feature_x1.ravel())),
        'x2': Feature(float_list=FloatList(value=feature_x2.ravel())),
        'y': Feature(int64_list=Int64List(value=label))
    })
)
Run Code Online (Sandbox Code Playgroud)

张量流版本是 1.7.0

python-3.x tensorflow

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

gcloud 命令更改当前目录的所有权

我正在执行从 GCP 获取 kubernetes 集群凭据的常规操作。该gcloud命令不会获取凭据并令人惊讶地更新本地目录的所有权:

~/tmp/1> ls
~/tmp/1> gcloud container clusters get-credentials production-ng
Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) Unable to write file [/home/vladimir/tmp/1]: [Errno 21] Is a directory: '/home/vladimir/tmp/1'

~/tmp/1> ls
ls: cannot open directory '.': Permission denied
Run Code Online (Sandbox Code Playgroud)

其他命令,如gcloud container clusters list工作正常。我试过重新安装gcloud.

gcloud kubectl

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

标签 统计

gcloud ×1

kubectl ×1

python-3.x ×1

tensorflow ×1