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

相关推荐
英姿202613 分钟前
敖维标签打印系统满足汽车标签打印
人工智能
IT_陈寒15 分钟前
Java的Stream.parallel()把我CPU跑爆了,这种优化要谨慎
前端·人工智能·后端
IvorySQL33 分钟前
IvorySQL Agent 探索与实践
数据库·人工智能·postgresql·oracle·ivorysql
谙忆10241 小时前
图片放大为什么会糊?从插值到AI超分,超分辨率技术是怎么演进的
人工智能·计算机视觉
程序员小杰@1 小时前
AI工程与开发生成:DeepMetier如何用AI生成CAD图纸、3D模型、代码和JSON
人工智能
阿黎梨梨1 小时前
Node.js 工程化路上的“路径”与“IO”避坑指南
人工智能
Listen·Rain1 小时前
提示词和提示词模板
java·人工智能·spring boot
阿里云大数据AI技术1 小时前
DataWorks Data Agent 实战课堂(一):解锁你的7×24h全能“数据搭子”DataWorks AI助理!
大数据·人工智能·agent
得一录2 小时前
大模型中Temperature的解释
人工智能
Database_Cool_2 小时前
阿里云RDS主从延迟解决方案_只读实例半同步复制最佳实践
数据库·人工智能