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

相关推荐
墨_浅-11 分钟前
20260805金融科技动向:《知识产权保护和运用“十五五”规划》金融机遇
人工智能·科技·金融
微硬创新18 分钟前
耐达讯自动化16路0-20mA转PROFINET协议转换模块技术说明
人工智能·网络协议·自动化·信息与通信
IT_陈寒1 小时前
我又被JavaScript的隐式类型转换坑了
前端·人工智能·后端
工业设备方案笔记1 小时前
RK3588 vs RK3568:AI边缘计算项目到底应该如何选择芯片平台?
arm开发·人工智能·目标跟踪·架构·边缘计算
Lee_jerome2 小时前
python神经网络编程入门(二十五)——IMDB 数据集预处理与词汇表构建
rnn·深度学习·词频统计·文本预处理·imdb数据集·词表构建·nlp入门
指尖的爷2 小时前
RKNN转化环境搭建(rknn_toolkit2新版本)
嵌入式硬件·深度学习·物联网·目标检测
windliang2 小时前
Claude Code 源码分析(七):Skill 如何进入 Agent
前端·人工智能·面试
PNP Robotics2 小时前
力控赋能具身|PNP机器人联合坤维亮相中国机器人学术年会
人工智能·机器学习·机器人
阿基拉de_Akir2 小时前
跨层禁止:机器如何拦截非法语义绑定
人工智能
名不经传的养虾人2 小时前
从0到1:企业级AI项目迭代日记 Vol.82|审批不再只写数据库,而是真正恢复执行
大数据·人工智能·ai编程·企业ai·多agent协作