Hi,
Here I have a simple 2-layers fully connected neural network, but I am not sure how I can convert input images to binary form in pytorch? Thank you in advance.
Data_tr = datasets.MNIST('../data', train=True, download=True,
                         transform=transforms.Compose([
                             transforms.Grayscale(),
                             transforms.ToTensor(),
                             transforms.Normalize((0.1307,), (0.3081,))]))

train_set = torch.utils.data.DataLoader(Data_tr, batch_size=batch_size, shuffle=True)
Data_ts = datasets.MNIST('../data', train=False, transform=transforms.Compose([
    transforms.Grayscale(),
    transforms.ToTensor(),
    transforms.Normalize((0.1307,), (0.3081,))]))


test_set = torch.utils.data.DataLoader(Data_ts, batch_size=batch_size, shuffle=True)

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(28 * 28, 64)
        self.fc2 = nn.Linear(64, 10)
        #W1 = list(self.fc1.parameters())
        #print("w1:", len(W1[1]))
        nn.init.xavier_normal_(self.fc1.weight)
        nn.init.xavier_normal_(self.fc2.weight)

    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = self.fc2(x)
        return F.log_softmax(x, dim=1)

net = Net()
print(net)