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

相关推荐
呆呆槑_Xiong3 分钟前
国内GEO生成式引擎优化公司对比 2026
人工智能
Dawson Zhu4 分钟前
大语言模型的本质:从条件概率预测到能力涌现的技术剖析
人工智能·语言模型·架构·aigc·agi
gzkuijing5 分钟前
MDI1PRD23B7‑EQ|Novanta IMS一体化RS-485/422步进电机参数、选型要点与典型应用
人工智能·机器学习·编辑器
能源科技集10 分钟前
不止于“大”:远景动力(AESC)790Ah电芯以系统级思维重塑储能技术路线
人工智能
骥龙18 分钟前
模块五:n8n自动化工作流 + Ollama + Health-MCP
人工智能·ai编程
jonyleek22 分钟前
工业物联网边缘计算架构设计:从数据采集到本地决策
人工智能·物联网·边缘计算·工业物联网·边缘网关·jvs物联网平台·iot架构
桐盛科技23 分钟前
拒绝“漂绿”风险:基于边缘计算的碳排放数据清洗算法与实时校验逻辑
人工智能·算法·边缘计算
Mr数据杨24 分钟前
汽车故障时间与类别预测实战 从 Kaggle 结构化赛题理解预测性维护建模
人工智能·数据分析·kaggle竞赛
147API35 分钟前
蒸馏项目什么时候该停,怎样切换到RAG、微调或模型路由
人工智能·深度学习·机器学习·数据挖掘
ltqvibe1 小时前
AI问数、找IT取数、自己导Excel,三条路怎么选
人工智能·excel·数据报表·智能问数·ai问数·本体语义·取数