from __future__ import print_function
import sys, os
sys.path.insert(1, os.path.join("..","..",".."))
import h2o
from tests import pyunit_utils
from h2o.estimators.deepwater import H2ODeepWaterEstimator

def lenet(num_classes):
    import mxnet as mx
    data = mx.symbol.Variable('data')
    # first conv
    conv1 = mx.symbol.Convolution(data=data, kernel=(5,5), num_filter=20)
    tanh1 = mx.symbol.Activation(data=conv1, act_type="tanh")
    pool1 = mx.symbol.Pooling(data=tanh1, pool_type="max", kernel=(2,2), stride=(2,2))
    # second conv
    conv2 = mx.symbol.Convolution(data=pool1, kernel=(5,5), num_filter=50)
    tanh2 = mx.symbol.Activation(data=conv2, act_type="tanh")
    pool2 = mx.symbol.Pooling(data=tanh2, pool_type="max", kernel=(2,2), stride=(2,2))
    # first fullc
    flatten = mx.symbol.Flatten(data=pool2)
    fc1 = mx.symbol.FullyConnected(data=flatten, num_hidden=500)
    tanh3 = mx.symbol.Activation(data=fc1, act_type="tanh")
    # second fullc
    fc2 = mx.symbol.FullyConnected(data=tanh3, num_hidden=num_classes)
    # loss
    lenet = mx.symbol.SoftmaxOutput(data=fc2, name='softmax')
    return lenet

def deepwater_custom_lenet_mnist():
  if not H2ODeepWaterEstimator.available(): return

  train = h2o.import_file(pyunit_utils.locate("bigdata/laptop/mnist/train.csv.gz"))
  test = h2o.import_file(pyunit_utils.locate("bigdata/laptop/mnist/test.csv.gz"))

  predictors = list(range(0,784))
  resp = 784
  train[resp] = train[resp].asfactor()
  test[resp] = test[resp].asfactor()
  nclasses = train[resp].nlevels()[0]

  print("Creating the lenet model architecture from scratch using the MXNet Python API")
  lenet(nclasses).save("/tmp/symbol_lenet-py.json")

  print("Importing the lenet model architecture for training in H2O")
  model = H2ODeepWaterEstimator(epochs=100, learning_rate=1e-3, mini_batch_size=64,
                                problem_type='data', ignore_const_cols=False,
                                network='user', network_definition_file="/tmp/symbol_lenet-py.json",
				image_shape=[28,28], channels=1)
                                
  model.train(x=predictors,y=resp, training_frame=train, validation_frame=test)
  model.show()
  error = model.model_performance(valid=True).mean_per_class_error()
  assert error < 0.1, "mean classification error on validation set is too high : " + str(error)

if __name__ == "__main__":
  pyunit_utils.standalone_test(deepwater_custom_lenet_mnist)
else:
  deepwater_custom_lenet_mnist()

@@ -344,35 +344,35 @@
 a=data, kernel=(
-5,5
+4,4
 ), num_filter=20
@@ -373,20 +373,20 @@
 ter=
+3
 2
-0
 )%0A    
-tanh
+relu
 1 = 
@@ -420,36 +420,36 @@
 onv1, act_type=%22
-tanh
+relu
 %22)%0A    pool1 = m
@@ -470,20 +470,20 @@
 ng(data=
-tanh
+relu
 1, pool_
@@ -598,11 +598,11 @@
 el=(
-5,5
+3,3
 ), n
@@ -615,20 +615,20 @@
 ter=
-50
+16
 )%0A    
-tanh
+relu
 2 = 
@@ -666,28 +666,28 @@
 , act_type=%22
-tanh
+relu
 %22)%0A    pool2
@@ -712,20 +712,20 @@
 ng(data=
-tanh
+relu
 2, pool_
@@ -760,24 +760,73 @@
 ride=(2,2))%0A
+    drop = mx.symbol.Dropout(data=pool2, p=0.2)%0A%0A
     # first 
@@ -868,21 +868,20 @@
 en(data=
-pool2
+drop
 )%0A    fc
@@ -938,21 +938,21 @@
 den=
-500
+128
 )%0A    
-tanh
+relu
 3 = 
@@ -996,15 +996,139 @@
 pe=%22
-tanh
+relu%22)%0A%0A    fc2 = mx.symbol.FullyConnected(data=relu3, num_hidden=64)%0A    relu4 = mx.symbol.Activation(data=fc2, act_type=%22relu
 %22)%0A
+%0A
     
@@ -1144,25 +1144,25 @@
 fullc%0A    fc
-2
+3
  = mx.symbol
@@ -1186,13 +1186,13 @@
 ata=
-tanh3
+relu4
 , nu
@@ -1221,21 +1221,8 @@
     
-# loss%0A    le
 net 
@@ -1254,17 +1254,17 @@
 (data=fc
-2
+3
 , name='
@@ -1284,18 +1284,16 @@
  return 
-le
 net%0A%0Adef
@@ -1959,18 +1959,102 @@
 pochs=10
-0
 ,
+%0A                                learning_rate=0.05, %0A                               
  learnin
@@ -2063,87 +2063,215 @@
 rate
+_annealing
 =1e-
-3, mini_batch_size=64,%0A                                problem_type='data',
+5, %0A                                momentum_start=0.9,%0A                                momentum_stable=0.9,%0A                                mini_batch_size=128,%0A                               
  ign
@@ -2327,24 +2327,8 @@
     
- network='user',
  net
@@ -2401,16 +2401,48 @@
 %5B28,28%5D,
+%0A                               
  channel
@@ -2574,16 +2574,61 @@
 .show()%0A
+  print(model.model_performance(valid=True))%0A
   error 

Modify the lenet mnist example to match szilard's benchmark-dl