Skip to content

Commit 0395ccb

Browse files
author
Mridul Jain
committed
Generate network graph
1 parent d7f3f82 commit 0395ccb

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

‎caffe-grid/src/main/python/DisplayUtils.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from IPython.display import HTML
44
import numpy as np
55
from base64 import b64encode
6-
from draw_net import parse_args
6+
from google.protobuf import text_format
7+
8+
import caffe
9+
import caffe.draw
10+
from caffe.proto import caffe_pb2
711

812
def get_np_array(row):
913
return np.frombuffer(row.data, 'uint8').reshape((row.height,row.width))
@@ -27,9 +31,12 @@ def show_df(df, nrows=10):
2731
html += "</table>"
2832
return HTML(html)
2933

30-
def show_network(input_net_proto_file, output_image_file):
31-
args = parse_args()
34+
def show_network(input_net_proto_file, rankdir):
3235
net = caffe_pb2.NetParameter()
33-
text_format.Merge(open(args.input_net_proto_file).read(), net)
34-
print('Drawing net to %s' % args.output_image_file)
35-
caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
36+
text_format.Merge(open(input_net_proto_file).read(), net)
37+
image=caffe.draw.draw_net(net, rankdir)
38+
html = "<body>"
39+
html += "<img src='data:image/png;base64," + b64encode(image) + "' />"
40+
html += "</body>"
41+
return HTML(html)
42+

‎data/lenet_dataframe_solver.prototxt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The train/test net protocol buffer definition
2-
net: "lenet_dataframe_train_test.prototxt"
2+
net: "/Users/mridul/bigml/CaffeOnSpark/data/lenet_dataframe_train_test.prototxt"
33
# test_iter specifies how many forward passes the test should carry out.
44
test_iter: 1
55
# Carry out testing every 500 training iterations.
@@ -20,4 +20,4 @@ max_iter: 10000
2020
snapshot: 5000
2121
snapshot_prefix: "mnist_lenet"
2222
# solver mode: CPU or GPU
23-
solver_mode: GPU
23+
solver_mode: CPU

‎data/lenet_dataframe_train_test.prototxt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ layer {
99
}
1010
source_class: "com.yahoo.ml.caffe.ImageDataFrame"
1111
memory_data_param {
12-
source: "hdfs:///projects/machine_learning/image_dataset/mnist_train_dataframe/"
12+
source: "/Users/mridul/bigml/mnist_train_dataframe/"
1313
batch_size: 64
1414
channels: 1
1515
height: 28
@@ -30,7 +30,7 @@ layer {
3030
}
3131
source_class: "com.yahoo.ml.caffe.ImageDataFrame"
3232
memory_data_param {
33-
source: "hdfs:///projects/machine_learning/image_dataset/mnist_test_dataframe/"
33+
source: "/Users/mridul/bigml/mnist_test_dataframe"
3434
batch_size: 100
3535
channels: 1
3636
height: 28

0 commit comments

Comments
 (0)