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

相关推荐
xsd202411181 小时前
Seedance 2导演Skill开源:让AI Agent变身视频创意总监
人工智能
冬奇Lab1 小时前
DeepSeek Harness 系列(05):Session 与记忆——对话历史是怎么活下来的
人工智能
DogDaoDao1 小时前
SimToolReal 解读:用“物体中心“视角重新定义灵巧工具操作
人工智能·机器人·github·关键点·人形机器人·gpt-4o·simtoolreal
冬奇Lab1 小时前
一天一个开源项目(第216篇):OpenViking - 给 AI Agent 装上可自进化的上下文数据库
人工智能·开源·资讯
一切皆是因缘际会1 小时前
从存量释放
人工智能
Xuantong_902 小时前
从 0 到 1 搭建本地 AI 工作环境:我的完整方案与经验总结
人工智能
晓窗科技2 小时前
口碑好的AI基座服务商
大数据·人工智能·python
一航jason2 小时前
Android平台推理框架及试用场景模型对比
android·人工智能·ai·架构·ai编程·llama
IT·陈寒2 小时前
Redis内存暴涨时,我忘记检查这个参数
人工智能·大模型·api·创业·变现·简历优化
东鸿电子Eastron2 小时前
AI 算力爆发,数据中心能源管理系统(EMS)正在经历什么?
人工智能·数据中心·智能电表·ai 算力·多回路计量·智能计量