braincog.base.utils package
Submodules
braincog.base.utils.criterions module
- class braincog.base.utils.criterions.MixLoss(ce_loss)
基类:
Module
混合损失函数, 可以将任意的损失函数与UnilateralMse损失混合 :param ce_loss: 任意的损失函数
- forward(x, target)
Defines the computation performed at every call.
Should be overridden by all subclasses.
备注
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
- class braincog.base.utils.criterions.UnilateralMse(thresh=1.0)
基类:
Module
扩展单边的MSE损失, 用于控制输出层的期望fire-rate 高于 thresh :param thresh: 输出层的期望输出频率
- forward(x, target)
Defines the computation performed at every call.
Should be overridden by all subclasses.
备注
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
braincog.base.utils.visualization module
- braincog.base.utils.visualization.plot_confusion_matrix(logits, labels, output_dir)
绘制混淆矩阵图 :param logits: predicted labels :param labels: true labels :param output_dir: 输出路径, 需要包括文件名以及后缀 :return: None
- braincog.base.utils.visualization.plot_mem_distribution(data, output_dir='', legend='', xlabel='Membrane Potential', ylabel='Density', **kwargs)
- braincog.base.utils.visualization.plot_tsne(x, colors, output_dir='', num_classes=None)
- braincog.base.utils.visualization.plot_tsne_3d(x, colors, output_dir='', num_classes=None)
绘制3D t-SNE聚类图, 直接将图片保存到输出路径 :param x: 输入的feature map / spike :param colors: predicted labels 作为不同类别的颜色 :param output_dir: 图片输出的路径(包括图片名及后缀) :return: None
- braincog.base.utils.visualization.spike_rate_vis(data, output_dir='')
- braincog.base.utils.visualization.spike_rate_vis_1d(data, output_dir='')
Module contents
- class braincog.base.utils.MixLoss(ce_loss)
基类:
Module
混合损失函数, 可以将任意的损失函数与UnilateralMse损失混合 :param ce_loss: 任意的损失函数
- forward(x, target)
Defines the computation performed at every call.
Should be overridden by all subclasses.
备注
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
- class braincog.base.utils.UnilateralMse(thresh=1.0)
基类:
Module
扩展单边的MSE损失, 用于控制输出层的期望fire-rate 高于 thresh :param thresh: 输出层的期望输出频率
- forward(x, target)
Defines the computation performed at every call.
Should be overridden by all subclasses.
备注
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
- braincog.base.utils.plot_confusion_matrix(logits, labels, output_dir)
绘制混淆矩阵图 :param logits: predicted labels :param labels: true labels :param output_dir: 输出路径, 需要包括文件名以及后缀 :return: None
- braincog.base.utils.plot_tsne(x, colors, output_dir='', num_classes=None)
- braincog.base.utils.plot_tsne_3d(x, colors, output_dir='', num_classes=None)
绘制3D t-SNE聚类图, 直接将图片保存到输出路径 :param x: 输入的feature map / spike :param colors: predicted labels 作为不同类别的颜色 :param output_dir: 图片输出的路径(包括图片名及后缀) :return: None