def stacked_autoencoder_predict(theta, input_size, hidden_size, num_classes, net_config, data):
 softmax_theta = theta[0:(hidden_size * num_classes)].reshape(num_classes, hidden_size)
 stack = params2stack(theta[(hidden_size * num_classes):], net_config)
 m = data.shape[1]
 a = [data]
 z = [np.array(0)]
 for s in stack:
  z.append((s['w'].dot(a[(-1)]) + np.tile(s['b'], (m, 1)).transpose()))
  a.append(sigmoid(z[(-1)]))
 pred = softmax.softmax_predict((softmax_theta, hidden_size, num_classes), a[(-1)])
 return pred

def stacked_autoencoder_predict ( theta , input_size , hidden_size , num_classes , net_config , data ) : softmax_theta = theta [ 0 : ( hidden_size * num_classes ) ] . reshape ( num_classes , hidden_size ) stack = params2stack ( theta [ ( hidden_size * num_classes ) : ] , net_config ) m = data . shape [ 1 ] a = [ data ] z = [ np . array ( 0 ) ] for s in stack : z . append ( ( s [ 'w' ] . dot ( a [ ( - 1 ) ] ) + np . tile ( s [ 'b' ] , ( m , 1 ) ) . transpose ( ) ) ) a . append ( sigmoid ( z [ ( - 1 ) ] ) ) pred = softmax . softmax_predict ( ( softmax_theta , hidden_size , num_classes ) , a [ ( - 1 ) ] ) return pred
takes a trained theta and a test data set .