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

相关推荐
时见先生6 小时前
Python库和conda搭建虚拟环境
开发语言·人工智能·python·自然语言处理·conda
昨夜见军贴06168 小时前
IACheck AI审核在生产型企业质量控制记录中的实践探索——全面赋能有关物质研究合规升级
大数据·人工智能
智星云算力8 小时前
智星云镜像共享全流程指南,附避坑手册(新手必看)
人工智能
盖雅工场9 小时前
驱动千店销售转化提升10%:3C零售门店的人效优化实战方案
大数据·人工智能·零售·数字化管理·智能排班·零售排班
Loo国昌9 小时前
深入理解 FastAPI:Python高性能API框架的完整指南
开发语言·人工智能·后端·python·langchain·fastapi
发哥来了9 小时前
【AI视频创作】【评测】【核心能力与成本效益】
大数据·人工智能
醉舞经阁半卷书19 小时前
Python机器学习常用库快速精通
人工智能·python·深度学习·机器学习·数据挖掘·数据分析·scikit-learn
产品何同学10 小时前
在线问诊医疗APP如何设计?2套原型拆解与AI生成原型图实战
人工智能·产品经理·健康医疗·在线问诊·app原型·ai生成原型图·医疗app
星爷AG I10 小时前
9-14 知觉整合(AGI基础理论)
人工智能·agi
开源技术10 小时前
Violit: Streamlit杀手,无需全局刷新,构建AI面板
人工智能·python