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

相关推荐
2501_933670792 分钟前
2027风控策略岗秋招准备:SQL、Excel、建模的优先级与项目路径
人工智能·sql·excel
小宋102110 分钟前
AI 生成内容如何证明来源:C2PA、Content Credentials 与签名校验
人工智能
zhousenshan12 分钟前
AgentScope 和 Spring AI Alibaba的区别
人工智能
奈落2412 分钟前
【RAG 深度修炼】专栏 · 第 9 期(收官):安全专题与生产 Checklist 总集——从能跑的 Demo 到睡得着觉的生产系统
大数据·网络·人工智能·安全·ai编程
超大青花鱼12 分钟前
Ubuntu20.04安装CUDA11.8教程
人工智能·深度学习·计算机视觉
golang学习记21 分钟前
Jetbrains 正式官宣:全新AI IDE正式发布!
ide·人工智能·intellij-idea·air
HZjiangzi22 分钟前
深耕精密驱动二十六载,捷昌驱动助力机器人产业升级发展
人工智能·算法
鬓戈32 分钟前
Claude Code frontend-design 插件调研 与 Vue 旧系统风格一致性方案
前端·vue.js·人工智能
BSD_CGQ36 分钟前
柔性触觉到工业称重:FSR 高精度工程化适配路径解析
大数据·人工智能·压力传感器·柔性薄膜压力传感器
一隅论数智36 分钟前
给AI找对“富矿“:本体协同的六大应用模式与落地战法
大数据·人工智能·经验分享·笔记·学习·学习方法·政务