深度学习(六十七)metal forge深度学习库使用
2024-09-18 02:36:47
1、设置输入:
let input = Input()
或者
let input = Input(width: 100, height: 100, channels: 3)
2、创建网络:
let output = input --> Resize(width: 28, height: 28) --> Convolution(kernel: (5, 5), channels: 20, activation: relu, name: "conv1") --> Dense(neurons: 10, name: "dense1") --> Softmax()
3、链接网络、加载参数
model = Model(input: input, output: output)
let success = model.compile(device: device, inflightBuffers: 3) { name, count, type in return ParameterLoaderBundle(name: name, count: count, suffix: type == .weights ? "_W" : "_b", ext: "bin") } if success { print(model.summary()) }
4、预测阶段:
model.encode(commandBuffer: commandBuffer, texture: inputTexture, inflightIndex: i)
let probabilities = model.outputImage(inflightIndex: i).toFloatArray() let top5 = probabilities.top(k: 5) let top5Labels = top5.map { x -> (String, Float) in (labels[x.0], x.1) }
最新文章
- 新手用git
- POI2005Bank notes银行货币
- C#学习笔记----AppDomain应用程序域
- Python基础:函数式编程
- portable runtime
- oracle 执行执行动态存储过程名---其实就是存储过程名是个字符串参数
- 百度网页搜索部来自Console的招聘信息
- WPF-控件-将ListBox条目水平排列
- 【leetcode】Word Break (middle)
- 自动匹配HTTP请求中对应实体参数名的数据(性能不是最优)
- 02--Java TCP Socket编程
- Automatic Generation of Animated GIFs from Video论文研读及实现
- xaf 如何添加logo信息
- 轻松学习java可重入锁(ReentrantLock)的实现原理
- Drupal性能优化:蜜蜂培训性能优化一
- python实现单单链表
- Configuring HDFS High Availability
- How can I set ccshared=-fPIC while executing ./configure?
- 454. 四数相加 II
- 在Eclipse中显示.project和.classpath和.setting目录