Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindelec.loss.NetWithEval

class mindelec.loss.NetWithEval(net_without_loss, constraints, loss='l2', dataset_input_map=None)[source]

Encapsulation class of network with loss of eval.

Parameters
  • net_without_loss (Cell) – The training network without loss definition.

  • constraints (Constraints) – The constraints function of pde problem.

  • loss (Union[str, dict, Cell]) – The name of loss function, e.g. “l1”, “l2” and “mae”. Default: “l2”.

  • dataset_input_map (dict) – The input map of the dataset Default: None.

Inputs:
  • inputs (Tensor) - The input is variable-length argument which contains network inputs and label.

Outputs:

Tuple, containing a scalar loss Tensor, a network output Tensor of shape (N,) and a label Tensor of shape (N,).

Supported Platforms:

Ascend

Examples

>>> import numpy as np
>>> from mindelec.loss import Constraints, NetWithEval
>>> from mindspore import Tensor, nn
>>> class Net(nn.Cell):
...     def __init__(self, input_dim, output_dim):
...         super(Net, self).__init__()
...         self.fc1 = nn.Dense(input_dim, 64)
...         self.fc2 = nn.Dense(64, output_dim)
...
...     def construct(self, *input):
...         x = input[0]
...         out = self.fc1(x)
...         out = self.fc2(out)
...         return out
>>> net = Net(3, 3)
>>> # For details about how to build the Constraints, please refer to the tutorial
>>> # document on the official website.
>>> constraints = Constraints(dataset, pde_dict)
>>> loss_network = NetWithEval(net, constraints)
>>> input = Tensor(np.ones([1000, 3]).astype(np.float32) * 0.01)
>>> label = Tensor(np.ones([1000, 3]).astype(np.float32))
>>> output_data = loss_network(input, label)