예제 #1
0
# span
clin = args.span / 2 * np.linspace(-1, 1, args.res)
cc1, cc2 = np.meshgrid(clin, clin)
cfeed = list(zip(cc1.ravel(), cc2.ravel()))

# loop over all points along surface direction
weights = evaluator.get_weights()

# get the already-logged data
print('Gathering already-evaluated indices')
xent = {}
acc = {}
api = API(rest_api_key='W2gBYYtc8ZbGyyNct5qYGR2Gl')
allexperiments = api.get('wronnyhuang/landscape2d')
for expt in allexperiments:
    if exptname != api.get_experiment_other(expt, 'Name')[0]: continue
    raw = api.get_experiment_metrics_raw(expt)
    for r in raw:
        if r['metricName'] == 'xent':
            xent[r['step']] = r['metricValue']
        elif r['metricName'] == 'acc':
            acc[r['step']] = r['metricValue']

for idx, (c1, c2) in enumerate(cfeed):

    if np.mod(idx, args.npart) != args.part: continue
    if idx in xent and idx in acc:
        print('skipping idx ' + str(idx))
        continue
    perturbedWeights = [
        w + c1 * d1 + c2 * d2 for w, d1, d2 in zip(weights, dw1, dw2)
예제 #2
0
class args:
    res = 256
    span = 2


# span
clin = args.span / 2 * np.linspace(-1, 1, args.res)
cc1, cc2 = np.meshgrid(clin, clin)
cfeed = np.array(list(zip(cc1.ravel(), cc2.ravel())))
data = -1 * np.ones(len(cfeed))

for expt in allexperiments:

    # filter experiments by name
    name = api.get_experiment_other(expt, 'Name')[0]
    if cleanpoison not in name: continue

    # merge data into cfeed
    raw = api.get_experiment_metrics_raw(expt)
    for r in raw:
        if r['metricName'] != xentacc: continue
        data[r['step']] = r['metricValue']

data = data.reshape(args.res, args.res)
contourf(cc1, cc2, data)
colorbar()
print(experiment.log_figure()['web'])

from scipy.io import savemat
savemat(xentacc + '_' + cleanpoison + '.mat', {'data': data})