Skip to content

Instantly share code, notes, and snippets.

@siakon89
Created March 29, 2020 18:29
Show Gist options
  • Save siakon89/df5a05b5309b46e15736e358d4fcffae to your computer and use it in GitHub Desktop.
Save siakon89/df5a05b5309b46e15736e358d4fcffae to your computer and use it in GitHub Desktop.
import sagemaker
from sagemaker.tensorflow import TensorFlow
from sagemaker import Session
sess = sagemaker.Session()
role = sagemaker.get_execution_role()
# Create the apropriate folder struture, no need to be the same as I use
train_dir = 'data/train'
test_dir = 'data/test'
np.save(os.path.join(train_dir, 'train_images.npy'), train_images)
np.save(os.path.join(train_dir, 'train_labels.npy'), train_labels)
np.save(os.path.join(test_dir, 'test_images.npy'), test_images)
np.save(os.path.join(test_dir, 'test_labels.npy'), test_labels)
print(f"Sagemaker bucket: {sess.default_bucket()}")
s3_prefix = 'fashion-mnist'
traindata_s3_prefix = '{}/data/train'.format(s3_prefix)
testdata_s3_prefix = '{}/data/test'.format(s3_prefix)
train_s3 = sagemaker.Session().upload_data(path='./data/train/', key_prefix=traindata_s3_prefix)
test_s3 = sagemaker.Session().upload_data(path='./data/test/', key_prefix=testdata_s3_prefix)
inputs = {'train':train_s3, 'test': test_s3}
print(inputs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment