You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.load.rst 1.3 kB

4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. mindspore.load
  2. =======================================
  3. .. py:class:: mindspore.load(file_name, **kwargs)
  4. 加载MindIR文件。
  5. 返回的对象可以由 `GraphCell` 执行,更多细节参见类 :class:`mindspore.nn.GraphCell` 。
  6. **参数:**
  7. - **file_name** (str) – MindIR文件名。
  8. - **kwargs** (dict) – 配置项字典。
  9. - **dec_key** (bytes) - 用于解密的字节类型密钥。 有效长度为 16、24 或 32。
  10. - **dec_mode** - 指定解密模式,设置dec_key时生效。可选项:'AES-GCM' | 'AES-CBC'。 默认值:“AES-GCM”。
  11. **返回:**
  12. Object,一个可以由 `GraphCell` 构成的可执行的编译图。
  13. **异常:**
  14. - **ValueError** – MindIR 文件名不正确。
  15. - **RuntimeError** - 解析MindIR文件失败。
  16. **样例:**
  17. >>> import numpy as np
  18. >>> import mindspore.nn as nn
  19. >>> from mindspore import Tensor, export, load
  20. >>>
  21. >>> net = nn.Conv2d(1, 1, kernel_size=3, weight_init="ones")
  22. >>> input_tensor = Tensor(np.ones([1, 1, 3, 3]).astype(np.float32))
  23. >>> export(net, input_tensor, file_name="net", file_format="MINDIR")
  24. >>> graph = load("net.mindir")
  25. >>> net = nn.GraphCell(graph)
  26. >>> output = net(input_tensor)
  27. >>> print(output)
  28. [[[[4. 6. 4.]
  29. [6. 9. 6.]
  30. [4. 6. 4.]]]]