o
    Ni                     @   st   d Z ddlmZ ddlmZ ddlmZ ddlmZ dZdZ	dZ
d	d
gZG dd dejjZG dd dejjZdS )Downsampled Imagenet dataset.    )absolute_import)division)print_functionNa6  @article{DBLP:journals/corr/OordKK16,
  author    = {A{"{a}}ron van den Oord and
               Nal Kalchbrenner and
               Koray Kavukcuoglu},
  title     = {Pixel Recurrent Neural Networks},
  journal   = {CoRR},
  volume    = {abs/1601.06759},
  year      = {2016},
  url       = {http://arxiv.org/abs/1601.06759},
  archivePrefix = {arXiv},
  eprint    = {1601.06759},
  timestamp = {Mon, 13 Aug 2018 16:46:29 +0200},
  biburl    = {https://dblp.org/rec/bib/journals/corr/OordKK16},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}
a   Dataset with images of 2 resolutions (see config name for information on the resolution).
It is used for density estimation and generative modeling experiments.

For resized ImageNet for supervised learning ([link](https://patrykchrabaszcz.github.io/Imagenet32/)) see `imagenet_resized`.
zhttp://image-net.org/small/32x3264x64c                       s*   e Zd ZdZejjd fdd	Z  ZS )DownsampledImagenetConfigz'BuilderConfig for Downsampled Imagenet.Nc                    s4   |t vr
tdt  tt| jdi | || _dS )zConstructs a DownsampledImagenetConfig.

    Args:
      data: `str`, one of `_DATA_OPTIONS`.
      **kwargs: keyword arguments forwarded to super.
    zdata must be one of %sN )_DATA_OPTIONS
ValueErrorsuperr   __init__data)selfr   kwargs	__class__r	   b/home/ubuntu/.local/lib/python3.10/site-packages/tensorflow_datasets/image/downsampled_imagenet.pyr   :   s   
z"DownsampledImagenetConfig.__init__)N)	__name__
__module____qualname____doc__tfdscoredisallow_positional_argsr   __classcell__r	   r	   r   r   r   7   s    r   c                   @   s6   e Zd ZdZdd eD Zdd Zdd Zdd	 Zd
S )DownsampledImagenetr   c              	   C   s.   g | ]}t |d | d tjdd|dqS )z7A dataset consisting of Train and Validation images of z resolution.z2.0.0z6New split API (https://tensorflow.org/datasets/splits))namedescriptionversionr   )r   r   r   Version).0config_namer	   r	   r   
<listcomp>L   s     
zDownsampledImagenet.<listcomp>c              	   C   s.   t jj| tt jdt jjddid dtdS )Nimagejpeg)encoding_formatz'http://image-net.org/small/download.php)builderr   featuressupervised_keyshomepagecitation)r   r   DatasetInfo_DESCRIPTIONr(   FeaturesDictImage	_CITATION)r   r	   r	   r   _infoY   s   zDownsampledImagenet._infoc                 C   sv   t d | jj d }t d | jj d }|||g\}}tjjtjjd|	|idtjjtjj
d|	|idgS )zReturns SplitGenerators.train_z.tarvalid_archive)r   
gen_kwargs)_DL_URLbuilder_configr   downloadr   r   SplitGeneratorSplitTRAINiter_archive
VALIDATION)r   
dl_manager	train_url	valid_url
train_path
valid_pathr	   r	   r   _split_generatorse   s"   


z%DownsampledImagenet._split_generatorsc                 c   s&    |D ]\}}d|i}||fV  qd S )Nr$   r	   )r   r4   fnamefobjrecordr	   r	   r   _generate_examples}   s   z&DownsampledImagenet._generate_examplesN)	r   r   r   r   r
   BUILDER_CONFIGSr1   rC   rG   r	   r	   r	   r   r   I   s    
r   )r   
__future__r   r   r   tensorflow_datasets.public_api
public_apir   r0   r-   r6   r
   r   BuilderConfigr   GeneratorBasedBuilderr   r	   r	   r	   r   <module>   s   