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

相关推荐
xsd202411185 小时前
Eye-in-Hand 还是 Eye-to-Hand?
人工智能
邂逅and回眸5 小时前
自进化的 Agent 是通往 AGI 的路吗
人工智能·agi
甲维斯6 小时前
GLM5.4“买家秀”来咯,这模型得...慢慢来!
人工智能
AI创界者7 小时前
Python 进阶实战(五十八章):配置热更新、优雅停机排空与高并发压测方案
人工智能·python·aigc
oak隔壁找我7 小时前
一款运行在 DSHDeepSeek Harness(DSH)中的 MySQL 客户端插件
人工智能
oak隔壁找我8 小时前
一款运行在 DSH(DeepSeek Harness)中的 Redis 管理插件
人工智能
孟健8 小时前
一个人做的免费AI工具,月访问千万的选品与技术拆解
人工智能·aigc
乌鲁木齐德润恒圣信息科技有限公司10 小时前
GEO生成式引擎优化:技术原理与43引擎自动测试系统
大数据·前端·人工智能
SelectDB11 小时前
SelectDB 和阿里云 SelectDB 有什么区别?公司关系、产品版本与部署方式详解
人工智能