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

相关推荐
lifallen1 分钟前
长任务怎样选择遗忘:clearing、compaction 与 memory
人工智能·学习·ai·ai编程
Luhui Dev3 分钟前
大角几何如何保证图片导出尺寸一致性?
人工智能·数学·ai·luhuidev
yyk333246 分钟前
卷积神经网络
人工智能·神经网络·cnn
翼龙云_cloud9 分钟前
腾讯云国际代理商:如何用云服务器快速部署WorkBuddy AI助手?
服务器·人工智能·云计算·腾讯云
我爱写代码i21 分钟前
边缘计算与小模型在工业预测性维护、机器视觉质检中有哪些具体的落地实施案例与架构设计?
人工智能·边缘计算
CCYe、28 分钟前
新模型上线、旧模型下线:企业AI网关如何管住模型版本
java·网络·数据库·人工智能
2601_9623008131 分钟前
机器学习的理想基石
人工智能·python·机器学习·编程语言·数据处理
audyxiao00133 分钟前
优秀博士学位论文分享|神经符号系统的非确定性管理研究
人工智能·神经符号系统·优博论文
falldeep36 分钟前
kl_loss为什么用k3?该放到reward中还是loss中?
人工智能·机器学习