Error when grabbing batches of data from training folder

I apologies in advance for what might be a complete lame question, but I can’t figure out a way around it.
I keep getting an error
OSError: [Errno 2] No such file or directory: '~/data/dogscats/sample/train’
when running
batches = vgg.get_batches(path+‘train’, batch_size=4)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
in ()
1 ##Grab batches of data from the training folder
----> 2 batches = vgg.get_batches(path+‘train’, batch_size=4)

/home/ubuntu/nbs/vgg16.pyc in get_batches(self, path, gen, shuffle, batch_size, class_mode)
     85     def get_batches(self, path, gen=image.ImageDataGenerator(), shuffle=True, batch_size=8, class_mode='categorical'):
     86         return gen.flow_from_directory(path, target_size=(224,224),
---> 87                 class_mode=class_mode, shuffle=shuffle, batch_size=batch_size)
     88 
     89 

/home/ubuntu/anaconda2/lib/python2.7/site-packages/keras/preprocessing/image.pyc in flow_from_directory(self, directory, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format)
    288             dim_ordering=self.dim_ordering,
    289             batch_size=batch_size, shuffle=shuffle, seed=seed,
--> 290             save_to_dir=save_to_dir, save_prefix=save_prefix, save_format=save_format)
    291 
    292     def standardize(self, x):

/home/ubuntu/anaconda2/lib/python2.7/site-packages/keras/preprocessing/image.pyc in __init__(self, directory, image_data_generator, target_size, color_mode, dim_ordering, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format)
    553         if not classes:
    554             classes = []
--> 555             for subdir in sorted(os.listdir(directory)):
    556                 if os.path.isdir(os.path.join(directory, subdir)):
    557                     classes.append(subdir)

OSError: [Errno 2] No such file or directory: '~/data/dogscats/sample/train'

My path is set to
path = "~/data/dogscats/sample/"
Also, I tried path = “data/dogscats/sample/”

Double checked in the terminal:
ubuntu@ip-10-0-0-4:~$ ls ~/data/dogscats/sample/train
cats dogs

I am sure it is something silly that I am missing. Thanks a lot for help!

I solved my own problem.
The issue was the the /data directory was outside of /nbs directory.
Once I moved it, it solved the problem.

the ~ refers to your home directory in the linux prompt but jupyter does not recognize that symbol, you either provide a full path (something like /home/yoursusename/data//dogscats/sample) or a correct relative path from the location where you launch jupyter

thank you @Gelu74

I found this confusing too.

I ended up with two nbs directories - one from the AMI and one from git clone:
~/nbs
~/courses/deeplearning1/nbs

got the same error as the OP.

I ended up just creating a ~data directory and symlink’ing to it from the nbs dirs.

ubuntu@ip-172-31-23-171:~/courses/deeplearning1/nbs$ ls -l data
rwxrwxrwx 1 ubuntu ubuntu 17 Feb 19 13:41 data -> /home/ubuntu/data