Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Sequence Models/Week 1/Dinosaur Island -- Character-level language model/__pycache__/shakespeare_utils.cpython-36.pyc
Views: 13420
3 ��qZ� � @ sf d dl mZ d dlmZ d dlmZmZmZ d dlm Z m Z mZmZm Z d dlmZ d dlmZ d dlmZ d dlZd dlZd dlZd dlZd#dd�Zd$d d�Zd%dd�Zdd� Zed� ejddd�j� j� Z d Z!e"e#e$e ���Z%e&dd� e'e%�D ��Z(e&dd� e'e%�D ��Z)ed� ee e!d d�\Z*Z+ed� ee*e+e,e%�e(d�\Z-Z.ed� ed �Z/d!d"� Z0dS )&� )�print_function)�LambdaCallback)�Model� load_model� Sequential)�Dense� Activation�Dropout�Input�Masking)�LSTM)�get_file)� pad_sequencesN�( � c C sd g }g }xDt dt| �| |�D ],}|j| ||| � � |j| || � qW tdt|�� ||fS )a� Create a training set by scanning a window of size Tx over the text corpus, with stride 3. Arguments: text -- string, corpus of Shakespearian poem Tx -- sequence length, number of time-steps (or characters) in one training example stride -- how much the window shifts itself while scanning Returns: X -- list of training examples Y -- list of training labels r znumber of training examples:)�range�len�append�print)�text�Tx�stride�X�Y�i� r �_/home/jovyan/work/Week 1/Dinosaur Island -- Character-level language model/shakespeare_utils.py� build_data s r c C s� t | �}tj|||ftjd�}tj||ftjd�}xPt| �D ]D\}} x&t| �D ]\} }d||| || f<