<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 讀取 Miku
Step1:  Muki NN
<img width=500px src='./muki_nn.png' />
<ASSISTANT_TASK:>
Python Code:
img_count = 0
def showimg(img):
    muki_pr = np.zeros((500,500,3))
    l =img.tolist()
    count = 0
    for x in range(500):
        for y in range(500):
            if l[count][0] >= .5:
                muki_pr[y][x] = 1
            else:
                muki_pr[y][x] = 0
                
            count += 1
    plt.imshow(muki_pr)
def saveimg(fname,img):
    muki_pr = np.zeros((500,500,3))
    l =img.tolist()
    count = 0
    for x in range(500):
        for y in range(500):
            if l[count][0] >= .5:
                muki_pr[y][x] = 1
            else:
                muki_pr[y][x] = 0
                
            count += 1
    plt.imsave(fname,muki_pr)
def read_muki():
    img_data = np.random.randn(250000,2)
    xy_data = []
    import random
    f = open('./muki.txt','rb')
    count = 0
    for line in f:
        y,x,c = line.split()
        xy_data.append([float(x),float(y)])
        
        x = (float(x) )*100. + 250
        y = (float(y) )*100. + 250
        c = float(c)
        
        if c >= 1:
            img_data[count] = (1,0)
        else:
            img_data[count] = (0,1)
            
            
#         img_data[count] = c
        
        count = count + 1
    return np.matrix(xy_data),img_data
xy_data,img_data = read_muki()    
showimg(img_data)
print xy_data[:10]
print img_data[:10]
Explanation: 讀取 Miku
End of explanation
from keras.models import Sequential
model = Sequential()
from keras.layers import Dense, Activation
from keras.optimizers import SGD
model.add(Dense(output_dim=128, input_dim=2))
model.add(Activation("relu"))
model.add(Dense(output_dim=128, input_dim=128))
model.add(Activation("relu"))
model.add(Dense(output_dim=8, input_dim=128))
model.add(Activation("relu"))
model.add(Dense(output_dim=2, input_dim=8))
model.add(Activation("softplus"))
model.compile(loss='mean_squared_error', optimizer=SGD(lr=0.05, momentum=0.9, nesterov=True), metrics=['accuracy'])
from IPython.display import SVG
from keras.utils.visualize_util import model_to_dot
SVG(model_to_dot(model).create(prog='dot', format='svg'))
for ii in range(50):
    model.fit(xy_data, img_data, nb_epoch=5, batch_size=500)
    result = model.predict(xy_data)
    saveimg('./imgs/muki_relu_'+ str(ii) +'.png', result)
result = model.predict(xy_data)
showimg(result)
Explanation: Muki NN
<img width=500px src='./muki_nn.png' />
End of explanation
<END_TASK>