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

相关推荐
掘金安东尼13 小时前
养龙虾之前?先搞懂 Skills!
人工智能
CoovallyAIHub13 小时前
OpenClaw 近 2000 个 Skills,为什么没有一个好用的视觉检测工具?
深度学习·算法·计算机视觉
CoovallyAIHub13 小时前
CVPR 2026 | 用一句话告诉 AI 分割什么——MedCLIPSeg 让医学图像分割不再需要海量标注
深度学习·算法·计算机视觉
CoovallyAIHub13 小时前
Claude Code 突然变成了 66 个专家?这个 5.8k Star 的开源项目,让我重新理解了什么叫"会用 AI"
深度学习·算法·计算机视觉
chaors14 小时前
从零学RAG0x03第一个实战应用:医疗知识混合检索实战
人工智能·aigc·ai编程
阿聪谈架构14 小时前
第02章:Prompt 工程 —— 用语言精准指挥 AI
人工智能
suke14 小时前
AI 界的 npm 惨案重演?聊聊 龙虾OpenClaw skills那些带毒的“骚操作
人工智能·程序员·aigc
明明如月学长14 小时前
OpneClaw 总挂?配个"保镖"自动修,7x24小时不用管
人工智能
万少15 小时前
用 OpenClaw 实现小红书自动发帖
人工智能
阿聪谈架构16 小时前
第01章:从零开始调用 LLM —— 入门 Qwen 大模型 API
人工智能