codecamp

TensorFlow函数:tf.keras.Input

tf.keras.Input函数

别名:

  • tf.keras.Input
  • tf.keras.layers.Input
tf.keras.Input(
    shape=None,
    batch_size=None,
    name=None,
    dtype=None,
    sparse=False,
    tensor=None,
    **kwargs
)

定义在:tensorflow/python/keras/_impl/keras/engine/input_layer.py.

Input()用于实例化Keras张量.

Keras张量是来自底层后端(Theano或TensorFlow)的张量对象,我们增加了某些属性,使我们能够通过了解模型的输入和输出来构建Keras模型.

例如,如果a,b和c是Keras张量,就有可能做到:model=Model(input=[a, b], output=c)

添加的Keras属性是_keras_history,应用于张量的最后一层.整个图层图可以递归地从该图层中检索.

参数:

  • shape:形状元组(整数),不包括批量大小.例如,shape=(32,),表示预期的输入将是32维向量的批次.
  • batch_size:可选的静态批量大小(整数).
  • name:图层的可选名称字符串.在模型中应该是唯一的(不要重复使用相同的名称两次).如果未提供,它将自动生成.
  • dtype:数据类型由输入预期的,作为字符串(float32,float64,int32...)
  • sparse:一个布尔值,指定是否创建占位符是稀疏的.
  • tensor:可选的现有张量包裹到Input图层中.如果设置,图层将不会创建占位符张量.
  • **kwargs:不支持的参数.

返回:

A tensor.

示例:

```python
# this is a logistic regression in Keras
x = Input(shape=(32,))
y = Dense(16, activation='softmax')(x)
model = Model(x, y)
```

可能引发的异常:

  • ValueError:在参数无效的情况下.
TensorFlow模块:tf.keras
TensorFlow函数教程:tf.keras.activations.deserialize
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }