from brainspy.utils import manager from bspytasks.boolean.logger import Logger from brainspy.utils.io import load_configs from brainspy.utils.transforms import ( DataToTensor, DataPointsToPlateau, DataToVoltageRange, ) from brainspy.processors.dnpu import DNPU V_MIN = [-1.2, -1.2] V_MAX = [0.6, 0.6] configs = load_configs("configs/boolean.yaml") data_transforms = transforms.Compose( [DataToVoltageRange(V_MIN, V_MAX, -1, 1), DataToTensor('cpu')] ) waveform_transforms = transforms.Compose( [DataPointsToPlateau(configs["processor"]["data"]["waveform"])] ) criterion = manager.get_criterion(configs["algorithm"]) algorithm = manager.get_algorithm(configs["algorithm"]) configs["current_dimension"] = 4 results = vc_dimension_test( configs, DNPU, criterion, algorithm,
plt.xlabel("Accuracy values") plt.ylabel("Counts") plt.savefig(os.path.join(save_dir, "accuracy_histogram_" + label + "." + extension)) if show_plots: plt.show() if __name__ == "__main__": from torchvision import transforms from brainspy.utils import manager from brainspy.utils.io import load_configs from brainspy.utils.transforms import DataToTensor, DataToVoltageRange from brainspy.processors.dnpu import DNPU V_MIN = [-1.2, -1.2] V_MAX = [0.6, 0.6] transforms = transforms.Compose( [DataToVoltageRange(V_MIN, V_MAX, -1, 1), DataToTensor(torch.device('cpu'))] ) configs = load_configs("configs/ring.yaml") criterion = manager.get_criterion(configs["algorithm"]) algorithm = manager.get_algorithm(configs["algorithm"]) search_solution(configs, DNPU, criterion, algorithm, transforms=transforms)
from brainspy.utils import manager from brainspy.utils.io import load_configs from brainspy.utils.transforms import DataToTensor, DataToVoltageRange, DataPointsToPlateau, ToDevice from brainspy.processors.dnpu import DNPU #TorchUtils.force_cpu = False V_MIN = [-1.2, -1.2] V_MAX = [0.6, 0.6] configs = load_configs("configs/ring.yaml") data_transforms = tfms.Compose([ DataToVoltageRange(V_MIN, V_MAX, -1, 1), DataToTensor(device=torch.device('cpu')) ]) # Add your custom transformations for the datapoints waveform_transforms = tfms.Compose([ # DataPointsToPlateau(configs['processor']['waveform']), ToDevice() ]) criterion = manager.get_criterion(configs["algorithm"]) algorithm = manager.get_algorithm(configs["algorithm"]) dataloaders = get_ring_data(configs, data_transforms) ring_task(configs, dataloaders, DNPU, criterion,