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) }

最新文章

  1. 新手用git
  2. POI2005Bank notes银行货币
  3. C#学习笔记----AppDomain应用程序域
  4. Python基础:函数式编程
  5. portable runtime
  6. oracle 执行执行动态存储过程名---其实就是存储过程名是个字符串参数
  7. 百度网页搜索部来自Console的招聘信息
  8. WPF-控件-将ListBox条目水平排列
  9. 【leetcode】Word Break (middle)
  10. 自动匹配HTTP请求中对应实体参数名的数据(性能不是最优)
  11. 02--Java TCP Socket编程
  12. Automatic Generation of Animated GIFs from Video论文研读及实现
  13. xaf 如何添加logo信息
  14. 轻松学习java可重入锁(ReentrantLock)的实现原理
  15. Drupal性能优化:蜜蜂培训性能优化一
  16. python实现单单链表
  17. Configuring HDFS High Availability
  18. How can I set ccshared=-fPIC while executing ./configure?
  19. 454. 四数相加 II
  20. 在Eclipse中显示.project和.classpath和.setting目录

热门文章

  1. 20145240《网络对抗》Web安全基础实践
  2. c++ 使用WinHTTP实现文件下载功能
  3. 什么时候使用namespace
  4. 【读书笔记】《深入浅出nodejs》第二章 模块机制
  5. Windows7使用无线网卡建立WiFi热点
  6. 源码编译nginx
  7. mysql常见知识点总结
  8. FASTQ format
  9. 计算java对象的内存占用
  10. Java获取系统环境信息