-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
I'm attempting to train this model in Tensorflow.JS, downloading it as such:
// Load the Fashion MNIST dataset
const urll = 'http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/';
const filenames = {
images: 'train-images-idx3-ubyte.gz',
labels: 'train-labels-idx1-ubyte.gz'
};
const loadFile = async (filename) => {
const url = `${urll}${filename}`;
const response = await fetch(url);
const buffer = await response.arrayBuffer();
return new Uint8Array(buffer);
};
const loadDataset = async () => {
const [imageData, labelData] = await Promise.all([
loadFile(filenames.images),
loadFile(filenames.labels)
]);
const imageTensor = tf.tensor(imageData.slice(16), [60000, 28, 28, 1]);
console.log(`imageTensor.shape: ${imageTensor.shape}`);
console.log(`imageData.byteLength: ${imageData.byteLength}`);
const labelTensor = tf.tensor(labelData.slice(8), [60000], 'int32');
console.log(`labelTensor.shape: ${labelTensor.shape}`);
console.log(`labelData.byteLength: ${labelData.byteLength}`);
return {
images: imageTensor,
labels: labelTensor
};
};
As I assume the training model has 60,000 images, 28x28 in greyscale, [60000, 28, 28, 1]
seems appropriate. However, I get the following error:
Error: Based on the provided shape, [60000,28,28,1], the tensor should have 47040000 values but has 26421864
Anything I've done wrong? Apologies if this isn't strictly on-topic, I don't have any other place to ask.
Metadata
Metadata
Assignees
Labels
No labels