gpt4 book ai didi

python - Anaconda & Tensorflow & Skflow : dnn() got an unexpected keyword argument 'keep_prob'

转载 作者:行者123 更新时间:2023-12-01 03:51:45 27 4
gpt4 key购买 nike

在 Anaconda 2.7 中运行此示例时:

import tensorflow.contrib.learn as skflow
def DNN_model(X, y):
"""This is DNN with 50, 20, 10 hidden layers, and dropout of 0.5 probability."""
layers = skflow.ops.dnn(X, [50, 30, 10], keep_prob=0.5)
return skflow.models.logistic_regression(layers, y)
clf = skflow.TensorFlowEstimator(model_fn=DNN_model, n_classes=3)

它转储以下问题:

dnn() got an unexpected keyword argument 'keep_prob'

Anaconda 中的 Tensorflow 安装使用:

conda install -c jjhelmus tensorflow=0.9.0

知道什么失败了吗?

最佳答案

根据repository看来这个版本已经贬值了:

learn.ops.dnn 已弃用,请使用 contrib.layers.dnn。

但是,应该传递不同的参数:

def dnn(tensor_in, hidden_units, activation=nn.relu, dropout=None):
"""Creates fully connected deep neural network subgraph.
This is deprecated. Please use contrib.layers.dnn instead.
Args:
tensor_in: tensor or placeholder for input features.
hidden_units: list of counts of hidden units in each layer.
activation: activation function between layers. Can be None.
dropout: if not None, will add a dropout layer with given probability.
Returns:
A tensor which would be a deep neural network.
"""

关于python - Anaconda & Tensorflow & Skflow : dnn() got an unexpected keyword argument 'keep_prob' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38120008/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com