preProbSquared = x * x l1loss = torch.sum(0.01 * torch.abs(preProbSquared)) window_size = (int(x.size()[2]), int(x.size()[3])) x = torch.nn.functional.avg_pool2d(x, kernel_size=window_size) x = torch.squeeze(x) probs = self.softmax(x) logprobs = torch.log(probs) nll = nllloss(logprobs, labels) loss = l1loss + nll return loss # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) c10driver.run(torchWriter, willowOptPatterns, args.outputdir, cifarInIndices, args.device, args.hw_id)
b = i[0:1].view(3, 1, 4) h0 = b[0:1, 0:4].view(1, 1, 4) c0 = b[1:2, 0:4].view(1, 1, 4) x = self.lstm(a, (h0, c0)) result = torch.cat((x[0], x[1][0], x[1][1])) l1loss = torch.sum(0.1 * torch.abs(result)) return l1loss # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) c10driver.run( torchWriter, popart.Patterns(['PreUniRepl', 'MulArgGradOp', 'AbsGradOp', 'OpToReshape']), args.outputdir, cifarInIndices, args.device, args.hw_id)
stride=1, padding=(1, 3), bias=False) self.relu = torch.nn.functional.relu def forward(self, inputs): """out = l1loss(relu(conv(in)))""" image0 = inputs[0] x = self.conv1(image0) x = self.relu(x) x = torch.sum(0.1 * torch.abs(x)) # l1loss return x # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) c10driver.run(torchWriter, None, args.outputdir, cifarInIndices, args.device, args.hw_id)
def forward(self, inputs): """out = relu(conv(in))""" image0 = inputs[0] x = self.conv1(image0) x = self.relu(x) return x # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, optimizer=optimizer, inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=samplesPerBatch) # Passes if torch and popart models match c10driver.run(torchWriter=torchWriter, patterns=None, outputdir=args.outputdir, cifarInIndices=cifarInIndices, device=args.device, device_hw_id=args.hw_id, mode="infer")
im0 = inputs[0] x = self.conv1(im0) x = self.in2(x) x = self.sin(x) return x # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, losses=losses, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) c10driver.run(torchWriter, None, args.outputdir, cifarInIndices, args.device, args.hw_id, transformations=["prepareNodesForTraining"], epochs=4)
# print(x.shape, inputs[2].shape) loss = nllloss(probs, inputs[2]) return loss # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) # As part of T16818 (model indeterminism) it is useful to # intercept the output directory here with something like #args.outputdir="/path/to/logging/dir/where/models/written/" c10driver.run(torchWriter, willowOptPatterns, args.outputdir, cifarInIndices, args.device, args.hw_id, printAnchorArrays=True)
# seq_length 3 # batch_size 1 # input_size 4 a = i[0:1].view(3, 1, 4) b = i[0:1].view(3, 1, 4) h0 = b[0:1, 0:4].view(1, 1, 4) c0 = b[1:2, 0:4].view(1, 1, 4) x = self.lstm(a, (h0, c0)) result = x[0] return result # Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) torchWriter = torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, losses=losses, optimizer=popart.ConstSGD(0.001), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize) c10driver.run(torchWriter, popart.Patterns(['PreUniRepl']), args.outputdir, cifarInIndices, args.device, args.hw_id)
# Set arbitrary seed so model weights are initialized to the # same values each time the test is run torch.manual_seed(1) # Test with ConstSGD anchors_1 = c10driver.run( torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, losses=losses, # default loss scaling (1.0f) optimizer=popart.SGD({"defaultLearningRate": (0.001, True)}), inputShapeInfo=inputShapeInfo, dataFlow=dataFlow, ### Torch specific: module=Module0(), samplesPerBatch=batchSize), willowOptPasses, args.outputdir, cifarInIndices, args.device, args.hw_id) # Test with ConstSGD anchors_2 = c10driver.run( torchwriter.PytorchNetWriter( inNames=inNames, outNames=outNames, losses=losses,