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

相关推荐
User_芊芊君子4 分钟前
第十五届中国创新创业大赛
人工智能
向哆哆4 分钟前
农场畜牧目标检测数据集:5类别、15,000张图像 | 目标检测
人工智能·目标检测·目标跟踪
Info X Med医学之家8 分钟前
成纤维细胞与肌成纤维细胞活化在组织修复和纤维化中的作用 | Info X Med 深度文献解读
人工智能·医学文献·info x med·医生
甲维斯8 分钟前
太吓人了!VibeCoding写的Bug空烧10000美金!
人工智能
匠测AI说12 分钟前
AI for Testing 提效实战·测试设计(四):我拿一个真实需求,让 AI 陪我走完了整个测试设计(全程复盘)
人工智能·测试
Omics Pro13 分钟前
研究证实AI虚拟细胞可用于药物靶点发现
数据库·人工智能·算法·机器学习·自然语言处理
柏慧通云报餐17 分钟前
智慧食堂食材溯源数字化方案|采购 - 入库 - 餐桌全链路记录体系落地实践
大数据·运维·人工智能
柯南466818 分钟前
【AI工程师精讲】涌现能力:能力在连续提升,还是尺子在骗人
人工智能·ai编程
在所不辞兄18 分钟前
常微分方程详解与应用
人工智能·神经网络·算法·机器学习
小鹿的周先生18 分钟前
第16章-RAG
java·人工智能·ai编程