Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1455c22

Browse filesBrowse files
authored
remove torchnet from requirements (qubvel-org#63)
1 parent 519af32 commit 1455c22
Copy full SHA for 1455c22

File tree

Expand file treeCollapse file tree

3 files changed

+63
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+63
-3
lines changed

‎requirements.txt

Copy file name to clipboard
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
torchvision>=0.2.2,<=0.3.0
1+
torchvision>=0.2.2,<=0.4.0
22
pretrainedmodels==0.7.4
3-
torchnet==0.0.4
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import numpy as np
2+
3+
4+
class Meter(object):
5+
'''Meters provide a way to keep track of important statistics in an online manner.
6+
This class is abstract, but provides a standard interface for all meters to follow.
7+
'''
8+
9+
def reset(self):
10+
'''Resets the meter to default settings.'''
11+
pass
12+
13+
def add(self, value):
14+
'''Log a new value to the meter
15+
Args:
16+
value: Next restult to include.
17+
'''
18+
pass
19+
20+
def value(self):
21+
'''Get the value of the meter in the current state.'''
22+
pass
23+
24+
25+
class AverageValueMeter(Meter):
26+
def __init__(self):
27+
super(AverageValueMeter, self).__init__()
28+
self.reset()
29+
self.val = 0
30+
31+
def add(self, value, n=1):
32+
self.val = value
33+
self.sum += value
34+
self.var += value * value
35+
self.n += n
36+
37+
if self.n == 0:
38+
self.mean, self.std = np.nan, np.nan
39+
elif self.n == 1:
40+
self.mean = 0.0 + self.sum # This is to force a copy in torch/numpy
41+
self.std = np.inf
42+
self.mean_old = self.mean
43+
self.m_s = 0.0
44+
else:
45+
self.mean = self.mean_old + (value - n * self.mean_old) / float(self.n)
46+
self.m_s += (value - self.mean_old) * (value - self.mean)
47+
self.mean_old = self.mean
48+
self.std = np.sqrt(self.m_s / (self.n - 1.0))
49+
50+
def value(self):
51+
return self.mean, self.std
52+
53+
def reset(self):
54+
self.n = 0
55+
self.sum = 0.0
56+
self.var = 0.0
57+
self.val = 0.0
58+
self.mean = np.nan
59+
self.mean_old = 0.0
60+
self.m_s = 0.0
61+
self.std = np.nan

‎segmentation_models_pytorch/utils/train.py

Copy file name to clipboardExpand all lines: segmentation_models_pytorch/utils/train.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import torch
33
from tqdm import tqdm as tqdm
4-
from torchnet.meter import AverageValueMeter
4+
from .meter import AverageValueMeter
55

66

77
class Epoch:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.