<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Autoencoder
This notebook demonstrates the invocation of the SystemML autoencoder script, and alternative ways of passing in/out data.
This notebook is supported with SystemML 0.14.0 and above.
Step1:  SystemML Read/Write data from local file system
Step3:  Generate Data and write out to file.
Step4:  Alternatively to passing in/out file names, use Python variables.
<ASSISTANT_TASK:>
Python Code:
!pip show systemml
import pandas as pd
from systemml import MLContext, dml
ml = MLContext(sc)
print(ml.info())
sc.version
Explanation: Autoencoder
This notebook demonstrates the invocation of the SystemML autoencoder script, and alternative ways of passing in/out data.
This notebook is supported with SystemML 0.14.0 and above.
End of explanation
FsPath = "/tmp/data/"
inp  = FsPath + "Input/"
outp = FsPath + "Output/"
Explanation: SystemML Read/Write data from local file system
End of explanation
import numpy as np
X_pd = pd.DataFrame(np.arange(1,2001, dtype=np.float)).values.reshape(100,20)
# X_pd = pd.DataFrame(range(1, 2001,1),dtype=float).values.reshape(100,20)
script =
    write(X, $Xfile)
prog = dml(script).input(X=X_pd).input(**{"$Xfile":inp+"X.csv"})
ml.execute(prog)
!ls -l /tmp/data/Input
autoencoderURL = "https://raw.githubusercontent.com/apache/systemml/master/scripts/staging/autoencoder-2layer.dml"
rets = ("iter", "num_iters_per_epoch", "beg", "end", "o")
prog = dml(autoencoderURL).input(**{"$X":inp+"X.csv"}) \
                          .input(**{"$H1":500, "$H2":2, "$BATCH":36, "$EPOCH":5 \
                                    , "$W1_out":outp+"W1_out", "$b1_out":outp+"b1_out" \
                                    , "$W2_out":outp+"W2_out", "$b2_out":outp+"b2_out" \
                                    , "$W3_out":outp+"W3_out", "$b3_out":outp+"b3_out" \
                                    , "$W4_out":outp+"W4_out", "$b4_out":outp+"b4_out" \
                                   }).output(*rets)
iter, num_iters_per_epoch, beg, end, o = ml.execute(prog).get(*rets)
print (iter, num_iters_per_epoch, beg, end, o)
!ls -l /tmp/data/Output
Explanation: Generate Data and write out to file.
End of explanation
autoencoderURL = "https://raw.githubusercontent.com/apache/systemml/master/scripts/staging/autoencoder-2layer.dml"
rets = ("iter", "num_iters_per_epoch", "beg", "end", "o")
rets2 = ("W1", "b1", "W2", "b2", "W3", "b3", "W4", "b4")
prog = dml(autoencoderURL).input(X=X_pd) \
                          .input(**{ "$H1":500, "$H2":2, "$BATCH":36, "$EPOCH":5}) \
                          .output(*rets) \
                          .output(*rets2)
result = ml.execute(prog)
iter, num_iters_per_epoch, beg, end, o = result.get(*rets)
W1, b1, W2, b2, W3, b3, W4, b4 = result.get(*rets2)
print (iter, num_iters_per_epoch, beg, end, o)
Explanation: Alternatively to passing in/out file names, use Python variables.
End of explanation
<END_TASK>