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

相关推荐
Nontee几秒前
腾讯 Hy4 开源:770B 旗舰,和一句“它参与了自己的训练“
人工智能·开源
一切皆是因缘际会5 分钟前
智能革新
人工智能·科技
Csvn10 分钟前
评测集不是“一堆问题”,是“测试资产”——30 条结构化评测集(E02)
人工智能·agent
OpenBayes16 分钟前
Qwen3.8-27B-FP8 降低大模型部署门槛,开启高效多模态智能体验;MiniMax H3-1K 发布千段视频测试数据集,全面评估 AI 视频生成能力
人工智能·深度学习·计算机视觉·自然语言处理·语音识别·多模态大模型
小小测试开发17 分钟前
RAG评测指标实战:忠实度、上下文精确率/召回率从原理到CI落地
android·人工智能·spring boot·ci/cd
Easy_API17 分钟前
OpenAI三周内第二次降价,GPT-5.6 Sol砍了20%到33
大数据·前端·人工智能·gpt·深度学习
小K讲AI营销19 分钟前
智谱配售314亿港元:融资通道切换
大数据·人工智能
陕西企来客24 分钟前
2026年8月木铝门窗适合哪些住宅?材质性能与维护解析
人工智能·材质·木铝门窗
深小乐25 分钟前
读李开复《AI 未来已来》,我三月份写的那些判断,被补全了
人工智能
张人玉25 分钟前
基于 Python + PyQt5 的水果目标检测与分割可视化系统——水果深度学习识别可视化大屏
python·深度学习·qt·目标检测·sqlite·echarts