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

相关推荐
老兵发新帖几秒前
next drawio界面卡死问题分析
人工智能·draw.io
一楼的猫8 分钟前
茄子写作助手——品牌搜索突破9万后的技术型品牌认知与官网入口指南
人工智能·学习·机器学习·chatgpt·ai写作
ZeroNews内网穿透10 分钟前
NAS部署Hermes AI Agent + 零讯内网穿透,实现远程可管理的AI助手
人工智能·安全·ai·内网穿透
隔窗听雨眠22 分钟前
原生一体化多模态大模型技术研究:从拼接到统一的架构革命
人工智能·架构
月疯29 分钟前
torch:expand和repeate的区别
开发语言·python·深度学习
羊羊小栈32 分钟前
Uplift营销供应链协同决策系统(基于Uplift因果推断与运筹优化算法)
前端·人工智能·算法·毕业设计·大作业
苏州邦恩精密36 分钟前
江苏三维扫描仪厂家如何选择合适的工业测量方案?
人工智能·科技·机器学习·3d·自动化·制造
humors22136 分钟前
100种社会实践
人工智能·程序人生
保卫大狮兄41 分钟前
什么是WBS项目管理?WBS有哪些核心功能?
大数据·人工智能
标书畅畅行42 分钟前
钛投标:全流程企业级AI标书解决方案,重构投标数字化生产力
大数据·人工智能