Deep Learning(3)

Linear Units in Keras

The easiest way to create a model in Keras is through 'keras.Sequential', which creates a stack of layers from a neural network. Of course, we can also use a dense layer to create the model.

We can define a linear model that takes three input features ('sugars', 'fiber', and 'protein') and then generate a simgle output ('calories') like this:

python 复制代码
from tensorflow import keras
from tensorflow.keras import layers

# Create a network with 1 linear unit
model = keras.Sequential([
    layers.Dense(units=1, input_shape=[3])
])

With the first parameter, 'units' , we define how many outputs we want. In this case, we're just predicting 'calories', so we'll use 'units = 1'.

With the second parameter, 'input_shape', we tell Keras the dimension of the inputs. Setting 'input_shape=3' ensures that the model will accept three features as input ('sugars', 'fiber', and 'protein').

This model is now ready to be fit to training data

相关推荐
七夜zippoe10 小时前
SoduWork 源码解读:从源码启动到验收签字的运行追踪
人工智能·ai·源码解读·soduwork
星栈10 小时前
我用 n8n 给自己搭了套 AI 流水线,先从干掉每天的复制粘贴开始
人工智能
意念回复11 小时前
Transformer 系列(三):Block 的两大子层——多头注意力(含 GQA)与 FFN(含 SwiGLU)
人工智能·深度学习·transformer
枫叶丹411 小时前
AI文本水印:生成机制、统计检测与误报
人工智能·机器学习·chatgpt·agent·codex
Cosolar11 小时前
让 Agent 别猜:一条禁止手写 SQL 的红线,撑起 23 万次可信取数
人工智能·llm·agent
AI创界者11 小时前
Python 进阶实战(七十三章):Python AI/LLM 应用工程化、流式响应与调用韧性实战
人工智能·python·aigc
楚山之石13 小时前
【Lancet】BRAID 随机试验:乳腺致密女性补充成像,abbreviated MRI 与 CEM 检出更多早期癌(首轮中期结果)
人工智能·科技·学习·mri·医学影像
小宋102115 小时前
Chrome 的 AI 功能在后台偷跑流量:把端侧模型做成可版本化的分发制品,用下载资格门控、差分更新与「下载未使用率」验收
大数据·人工智能·chrome