示例#1
0
def quick_inspect(cellid="chn020f-b1", batch=271,
                  modelname="ozgf100ch18_wc18x1_fir15x1_lvl1_dexp1_fit01"):
    """
    DEPRECATED? pretty much replaced by xhelp.load_model_xform()
    """
    xf, ctx = load_model_baphy_xform(cellid, batch, modelname, eval_model=True)

    modelspec = ctx['modelspec']
    est = ctx['est']
    val = ctx['val']
    nplt.quickplot(ctx)

    return modelspec, est, val
示例#2
0
def plot_summary(modelspecs, val, figures=None, IsReload=False, **context):
    # CANNOT initialize figures=[] in optional args our you will create a bug

    if figures is None:
        figures = []
    if not IsReload:
        fig = nplt.quickplot({'modelspecs': modelspecs, 'val': val})
        # Needed to make into a Bytes because you can't deepcopy figures!
        figures.append(nplt.fig2BytesIO(fig))

    return {'figures': figures}
示例#3
0
ax = plt.subplot(3, 1, 1)
nplt.spectrogram_from_epoch(val['stim'], epoch, ax=ax, time_offset=2)

ax = plt.subplot(3, 1, 2)
nplt.timeseries_from_epoch([val['resp']], epoch, ax=ax)

raster = rec['resp'].extract_epoch(epoch)
ax = plt.subplot(3, 1, 3)
plt.imshow(raster[:, 0, :])

plt.tight_layout()

# see what a "traditional" NEMS model looks like
nems_modelname = "ozgf.fs100.ch18-ld-sev_dlog-wc.18x2.g-do.2x15-lvl.1-dexp.1_init-basic"
xfspec, ctx = load_model_xform(cellid, batch=batch, modelname=nems_modelname)
nplt.quickplot(ctx)

ex = gui.browse_xform_fit(ctx, xfspec)

##
batch, cellid = 308, 'AMT018a-09-1'
modelname = 'ozgf.fs100.ch18-ld-sev_dlog-wc.18x4.g-fir.2x15x2-relu.2-wc.2x1-lvl.1-dexp.1_init.tf.rb5-tf.n'
xfspec, ctx = fit_model_xform(cellid, batch=batch, modelname=modelname)
nplt.quickplot(ctx)
ex = gui.browse_xform_fit(ctx, xfspec)

###Plot complexity of model versus how effective it was
batch = 308
metric = 'r_test'
metric2 = 'n_parms'
metric3 = 'se_test'
示例#4
0
# uncomment to save model to disk:

# logging.info('Saving Results...')
# ms.save_modelspecs(modelspecs_dir, modelspecs)

# ----------------------------------------------------------------------------
# GENERATE PLOTS
#
# GOAL: Plot the predictions made by your results vs the real response.
#       Compare performance of results with other metrics.

log.info('Generating summary plot...')

# Generate a summary plot
context = {'val': val, 'modelspecs': modelspec.fits(), 'est': est}
fig = nplt.quickplot(context)
fig.show()

# Optional: uncomment to save your figure
# fname = nplt.save_figure(fig, modelspecs=modelspecs, save_dir=modelspecs_dir)

# browse the validation data
#aw = browse_recording(val, signals=['stim', 'pred', 'resp'], cellid=cellid)

# ----------------------------------------------------------------------------
# SHARE YOUR RESULTS

# GOAL: Upload your resulting models so that you can see how well your model
#       did relative to other peoples' models. Save your results to a DB.

# TODO
示例#5
0
    def view_model(self):

        xf, ctx = self.get_current_selection()
        nplt.quickplot(ctx)
示例#6
0
# ----------------------------------------------------------------------------
# SAVE YOUR RESULTS

# GOAL: Save your results to disk. (BEFORE you screw it up trying to plot!)

# logging.info('Saving Results...')
# ms.save_modelspecs(modelspecs_dir, modelspecs)

# ----------------------------------------------------------------------------
# GENERATE PLOTS
#
# GOAL: Plot the predictions made by your results vs the real response.
#       Compare performance of results with other metrics.

logging.info('Generating summary plot...')

# Generate a summary plot
fig = nplt.quickplot({'val': val, 'modelspecs': modelspecs})
#fig.show()

# Optional: Save your figure
#fname = nplt.save_figure(fig, modelspecs=modelspecs, save_dir=modelspecs_dir)

# ----------------------------------------------------------------------------
# SHARE YOUR RESULTS

# GOAL: Upload your resulting models so that you can see how well your model
#       did relative to other peoples' models. Save your results to a DB.

# TODO
示例#7
0
文件: test_cnn.py 项目: LBHB/NEMS
plt.subplot(2, 1, 2)

respidx = 0
plt.plot(Dv[respidx, :, 0])
plt.plot(Dv_pred[respidx, :, 0])
cc = np.corrcoef(Dv.flatten(), Dv_pred.flatten())
plt.title('prediction corr: {:.3f}'.format(cc[0, 1]))

if USE_LINK:
    modelspec = cnnlink.cnn2modelspec(net2, modelspec)
    est, val = nems.analysis.api.generate_prediction(est, val, modelspec)

    # evaluate prediction accuracy
    modelspec = nems.analysis.api.standard_correlation(est, val, modelspec)

    nplt.quickplot({'val': val, 'modelspec': modelspec})
"""
net1_seed = 7
tf.reset_default_graph()
net1 = cnn.Net(data_dims, n_feats, sr_Hz, deepcopy(layers), seed=net1_seed, log_dir=modelspecs_dir)
net1.build()
net1_layer_vals = net1.layer_vals()
#D = net1.predict(F)
D = np.reshape(est['resp'].as_continuous().T, data_dims)

net2_seed = 10
tf.reset_default_graph()
net2 = cnn.Net(data_dims, n_feats, sr_Hz, deepcopy(layers), seed=net2_seed, log_dir=modelspecs_dir)
net2.optimizer = 'GradientDescent'

net2.build()
示例#8
0
modelname = 'ozgf100ch18_wc18x1_fir1x15_lvl1_dexp1_fit01'

#cellid = 'BRT026c-16-1'
#batch = 301
#modelname = 'nostim20pupbeh_stategain3_fitpjk01'

# fit the model (only need this if it hasn't been done before)
#fit_model_xforms_baphy(
#        cellid='TAR010c-18-1', batch=271,
#        modelname='ozgf100ch18_wc18x1_fir15x1_lvl1_dexp1_fit01',
#        saveInDB=True,
#        )

# load the fitted modelspec
xfspec, ctx = load_model_baphy_xform(cellid=cellid,
                                     batch=batch,
                                     modelname=modelname,
                                     eval_model=True)

# can pass 'figsize' argument to override default sizing.
# otherwise will be   width = 10 inches x width_mult
#                     height = 1 inch/plot x height_mult
# use epoch=str and occurence=int to control which epoch and occurence
# get displayed for epoch-dependent plots.
fig = nplt.quickplot(ctx,
                     height_mult=3.5,
                     width_mult=1.2,
                     epoch='TRIAL',
                     occurrence=0)
plt.show()