add context example of graph cell

This commit is contained in:
lianliguang 2023-03-01 09:50:44 +08:00
parent 34ba528c42
commit d7e9a2c396
2 changed files with 4 additions and 0 deletions

View File

@ -2243,6 +2243,8 @@ class GraphCell(Cell):
>>> import mindspore as ms
>>> import mindspore.nn as nn
>>> from mindspore import Tensor
>>> from mindspore import context
>>> context.set_context(mode=context.GRAPH_MODE)
>>>
>>> net = nn.Conv2d(1, 1, kernel_size=3, weight_init="ones")
>>> input = Tensor(np.ones([1, 1, 3, 3]).astype(np.float32))

View File

@ -412,6 +412,8 @@ def load(file_name, **kwargs):
>>> import mindspore as ms
>>> import mindspore.nn as nn
>>> from mindspore import Tensor
>>> from mindspore import context
>>> context.set_context(mode=context.GRAPH_MODE)
>>>
>>> net = nn.Conv2d(1, 1, kernel_size=3, weight_init="ones")
>>> input_tensor = Tensor(np.ones([1, 1, 3, 3]).astype(np.float32))