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

相关推荐
watersink3 分钟前
LocateAnything解读
人工智能
FrameNotWork9 分钟前
HarmonyOS6.1 从图像分类到目标检测的扩展实现
人工智能·harmonyos
智联物联18 分钟前
办公楼转型养老公寓,边缘计算网关实现全场景智慧监护
人工智能·边缘计算·物联网解决方案·工业网关·智慧养老·数采网关·边缘盒子
库拉大叔19 分钟前
工具调用效率对比实测:GPT-5.5与Gemini 3.5 Flash性能评估
java·前端·人工智能
智讯天下35 分钟前
专业的高端智能照明品牌哪家好?从光学技术、系统稳定性、设计认证、服务保障四个维度看
人工智能·智能手机
xiami_world39 分钟前
2026年UI/UX设计工具私有化部署方案深度解析
人工智能·ui·ai·产品经理·ux
无忧智库1 小时前
基于C4ISR与数据链的智慧应急体系:从“透明战场”到“透明城市”的数字化指挥解决方案(170页PPT)
大数据·人工智能·智慧城市
罗小罗同学1 小时前
哈佛团队在Nat Med发表医学AI模型,可以在任务推理阶段实时调整推理方式,无需重新训练
人工智能·医学图像处理·医工交叉·医学ai
杭州默安科技1 小时前
AI挖掘0day漏洞常态化,企业网络防御该如何破局?
人工智能·网络安全