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

相关推荐
Raink老师5 小时前
【AI面试临阵磨枪】Harness 的环境隔离(沙箱)如何设计?文件、网络、命令、权限四层隔离?
人工智能·ai 面试
人工智能AI技术6 小时前
Python 断言 assert 基础用法
人工智能
我是发哥哈6 小时前
横向评测:五款主流AI培训课程效果与选型分析
人工智能
GetcharZp6 小时前
告别昂贵显卡!llama.cpp 终极指南:在你的电脑上满速运行大模型!
人工智能
AI木马人6 小时前
3.【Prompt工程实战】如何设计一个可复用的Prompt系统?(避免每次手写提示词)
linux·服务器·人工智能·深度学习·prompt
Agent产品评测局6 小时前
临床前同源性反应种属筛选:利用AI Agent加速筛选的实操方案 —— 2026企业级智能体选型与技术落地指南
人工智能·ai·chatgpt
ting94520007 小时前
HunyuanOCR 全方位深度解析
人工智能·架构
woai33647 小时前
AI通识-大模型的原理&应用
人工智能
头发够用的程序员7 小时前
从滑动窗口到矩阵运算:img2col算法基本原理
人工智能·算法·yolo·性能优化·矩阵·边缘计算·jetson
ydmy7 小时前
transformer超参数配置(个人理解)
人工智能·深度学习