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

相关推荐
Dylan~~~4 分钟前
深度解析:AI Agent的底层原理
人工智能
每天吃的很好的Ruby5 分钟前
报错ValueError: sampler option is mutually exclusive with shuffle
人工智能·pytorch·python
研知有术一站式科研平台7 分钟前
研知有术论文辅导丨文献综述的三种类型和写法(附直接能用的写作模板)
人工智能·经验分享·机器学习·数据挖掘·论文笔记
羽翼安全10 分钟前
华为机密是如何防止拍照泄密的?公司防止员工拍摄电脑屏幕的深度选型指南
人工智能
空空潍19 分钟前
Spring AI 实战系列(四):Prompt工程深度实战
java·人工智能·spring·prompt
高洁0125 分钟前
【无标题】如何利用知识图谱实现推理和计算
人工智能·机器学习·数据挖掘·transformer·知识图谱
AI袋鼠帝27 分钟前
终于找到免费的本地Agent了!量大管饱,真干活~
人工智能·aigc
梦想很大很大29 分钟前
一个推荐系统是如何“长大”的(工程演进)
人工智能·机器学习·架构
AI程序员43 分钟前
Code Agent 的上下文压缩:不是 zip,而是工作记忆管理
人工智能
AI程序员44 分钟前
OpenAI Frontier 到底是什么:企业 Agent 不只是需要一个更强的模型
人工智能