code: """
   Copyright (c) 2018 Intel Corporation
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  """
  
  import torch.nn as nn
  
  from model.blocks.shared_blocks import SELayer
  
  
  class InvertedResidual(nn.Module):
      """Implementation of the modified Inverted residual block"""
      def __init__(self, in_channels, out_channels, stride, expand_ratio, outp_size=None):
          super(InvertedResidual, self).__init__()
          self.stride = stride
          assert stride in [1, 2]
  
          self.use_res_connect = self.stride == 1 and in_channels == out_channels
  
          self.inv_block = nn.Sequential(
              nn.Conv2d(in_channels, in_channels * expand_ratio, 1, 1, 0, bias=False),
              nn.BatchNorm2d(in_channels * expand_ratio),
              nn.PReLU(),
  
              nn.Conv2d(in_channels * expand_ratio, in_channels * expand_ratio, 3, stride, 1,
                        groups=in_channels * expand_ratio, bias=False),
              nn.BatchNorm2d(in_channels * expand_ratio),
              nn.PReLU(),
  
              nn.Conv2d(in_channels * expand_ratio, out_channels, 1, 1, 0, bias=False),
              nn.BatchNorm2d(out_channels),
              # SELayer(out_channels, 8, nn.PReLU, outp_size)
          )
  
      def forward(self, x):
          if self.use_res_connect:
              return x + self.inv_block(x)
  
          return self.inv_block(x)
   from tensorboard.backend.event_processing import event_accumulator
  
  ea=event_accumulator.EventAccumulator('../logs_landm/2019_08_04_14_38_LandNet-NoSE/events.out.tfevents.1564900704.Workstation')
  ea.Reload()
  # print(ea.scalars.Keys())
  # ea1=event_accumulator.EventAccumulator('./dsm_aug/eval_0/events.out.tfevents.1562407251.Workstation')
  # ea1.Reload()
  # print(ea.scalars.Keys())
  
  # print([(i.step, i.value) for i in class_loss])
  import matplotlib.pyplot as plt
  fig, axes = plt.subplots(3, 1)
  loss=ea.scalars.Items('Loss/train_loss')
  axes[0].plot([i.step for i in loss],[i.value for i in loss],label='loss', linewidth=1)
  axes[0].set_xlim(0)
  axes[0].set_ylim(0, 0.2)
  axes[0].set_yticks([0.02, 0.1, 0.2])
  axes[0].grid(True, linestyle='-.')
  
  avg_error=ea.scalars.Items('Quality/Avg_error')
  axes[1].plot([i.step for i in avg_error],[i.value for i in avg_error],label='avg_error', linewidth=1, color='mediumblue')
  axes[1].set_xlim(0)
  axes[1].set_ylim(0, 0.4)
  axes[1].set_yticks([0.2, 0.04, 0.4])
  axes[1].grid(True, linestyle='-.')
  
  fr=ea.scalars.Items('Quality/Failure_rate')
  axes[2].plot([i.step for i in fr],[i.value for i in fr],label='failure_rate', linewidth=1, color='c')
  axes[2].set_xlim(0)
  axes[2].set_yticks([1,0.5,0.04])
  axes[2].grid(True, linestyle='-.')
  axes[0].set_ylabel("Loss")
  axes[1].set_ylabel("NME")
  axes[2].set_ylabel("Failure rate")
  axes[2].set_xlabel("step")
  plt.show()
apis: torch.nn.PReLU torch.nn.BatchNorm2d torch.nn.Conv2d
apis: matplotlib.pyplot.show matplotlib.pyplot.subplots