Skip to content

Commit 04e6d36

Browse files
author
Gaurav Bhatt
authored
Add files via upload
1 parent 95b565a commit 04e6d36

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

week5/map.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/python
2+
3+
# Format of each line is:
4+
# date\ttime\tstore name\titem description\tcost\tmethod of payment
5+
#
6+
# We want elements 2 (store name) and 4 (cost)
7+
# We need to write them out to standard output, separated by a tab
8+
9+
import sys
10+
11+
for line in sys.stdin:
12+
d = line.split()
13+
for i in d:
14+
print "{0}\t{1}".format(i,1)

week5/my.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Thanks for the response.
2+
For the references to "time", I have the similar concern as you, but it's not easy to find one which is abstract and explicit.
3+
4+
In real world, and in the context of CNN, 3D data usually means 3D volume or 2D movie. For 3D volume, it's spatial signal. And for movie, it's spatio-temporal signal. Names such as "first_spatial_dim", "second_spatial_dim" etc. would not apply in the case of a movie, because, time dimension for a movie is not the "first spatial dim", it's a temporal dim.

week5/red.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/python
2+
3+
import sys
4+
5+
salesTotal = 0
6+
#salesTotal = []
7+
oldKey = None
8+
9+
# Loop around the data
10+
# It will be in the format key\tval
11+
# Where key is the store name, val is the sale amount
12+
#
13+
# All the sales for a particular store will be presented,
14+
# then the key will change and we'll be dealing with the next store
15+
16+
for line in sys.stdin:
17+
data_mapped = line.strip().split("\t")
18+
if len(data_mapped) != 2:
19+
# Something has gone wrong. Skip this line.
20+
continue
21+
22+
thisKey, thisSale = data_mapped
23+
24+
if oldKey and oldKey != thisKey:
25+
print oldKey, "\t", salesTotal
26+
oldKey = thisKey;
27+
salesTotal = 0
28+
29+
oldKey = thisKey
30+
salesTotal += float(thisSale)
31+
#salesTotal.append(thisSale)
32+
33+
if oldKey != None:
34+
print oldKey, "\t", salesTotal

0 commit comments

Comments
 (0)