forked from Rithwikksvr/EdgeNILM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputations_checker.py
48 lines (33 loc) · 1000 Bytes
/
computations_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import pandas as pd
import time
import math
import matplotlib.pyplot as plt
import os
import math
import torch
from torch import nn
import torch.nn.functional as F
import torch.optim as optim
from collections import OrderedDict
import time
import sys
from functions import *
from networks import Seq2Point
from pthflops import count_ops
from torchsummary import summary
os.environ["CUDA_VISIBLE_DEVICES"]=""
class sillymodel(nn.Module):
def __init__(self):
super(sillymodel, self).__init__()
self.conv1 = torch.nn.Conv1d(out_channels = 30 , kernel_size=10, in_channels = 1)
def forward(self, X):
x = self.conv1(X)
x = F.relu(x)
return x
sequence_length = 99
model = Seq2Point(99,False)#sillymodel()
model.to('cpu')
print (summary(model, (1, sequence_length)))
flops_tensor = torch.rand(1,1,sequence_length).to('cpu')
total_flops=count_ops(model, flops_tensor)[0]