예제 #1
0
def main():
    """Create and execute an experiment."""
    model = AnalogSequential(
        Flatten(),
        AnalogLinear(INPUT_SIZE,
                     HIDDEN_SIZES[0],
                     True,
                     rpu_config=SingleRPUConfig(device=ConstantStepDevice())),
        Sigmoid(),
        AnalogLinear(HIDDEN_SIZES[0],
                     HIDDEN_SIZES[1],
                     True,
                     rpu_config=SingleRPUConfig(device=ConstantStepDevice())),
        Sigmoid(),
        AnalogLinear(HIDDEN_SIZES[1],
                     OUTPUT_SIZE,
                     True,
                     rpu_config=SingleRPUConfig(device=ConstantStepDevice())),
        LogSoftmax(dim=1))

    # Create the training Experiment.
    experiment = BasicTraining(dataset=FashionMNIST,
                               model=model,
                               epochs=EPOCHS,
                               batch_size=BATCH_SIZE)

    # Create the runner and execute the experiment.
    runner = LocalRunner(device=DEVICE)
    results = runner.run(experiment, dataset_root=PATH_DATASET)
    print(results)
예제 #2
0
    def get_experiment(self,
                       real: bool = False,
                       rpu_config: Any = EcRamPreset):
        """Return a BasicTraining experiment."""
        argv = {
            'dataset': FashionMNIST,
            'model': self.get_model(rpu_config),
            'epochs': 30,
            'batch_size': 8,
            'learning_rate': 0.01
        }

        if not real:
            argv['epochs'] = 1

        return BasicTraining(**argv)
예제 #3
0
    def get_experiment(self,
                       real: bool = False,
                       rpu_config: Any = IdealizedPreset):
        """Return a BasicTraining experiment."""
        argv = {
            'dataset': SVHN,
            'model': self.get_model(rpu_config),
            'epochs': 20,
            'batch_size': 10,
            'learning_rate': 0.01
        }

        if not real:
            argv['epochs'] = 1

        return BasicTraining(**argv)