1234567891011121314151617181920 |
- import numpy as np
- import mxnet as mx
- from mxnet import nd
- import snlay as snlay
- def mxmod_arr_loss(x, target, mxmodel):
- x_np = np.array(x)
- x_np = (x_np - 50.0)/20.0
- res2 = mxmodel.predict(x_np)
- y_t = nd.array(target, ctx=mx.gpu())
- err = nd.abs(y_t - res2)/y_t
- err2 = 100*nd.mean(err, axis=1).asnumpy()
- return err2
- def loss_func(x, target, mats, lams):
- spec_ac = snlay.calc_spectrum(x, mats, lams)
- diff = np.abs(target - spec_ac)/target
- return 100*np.amax(diff)
|