### Resource retrieval

Retrieve the resource object:

Out[1]= | |

Get the pre-trained network:

Out[2]= | |

### Basic usage

Predict the next character of a given sequence:

Out[3]= | |

Get the top 15 probabilities:

Out[4]= | |

Plot the top 15 probabilities:

Out[5]= | |

### Generation

Generate text with temperature sampling. First split the net into two parts:

Define a function for efficient generation using NetStateObject:

Generate for 100 steps using “def parse” as an initial string:

Out[9]= | |

The third optional argument is a “temperature” parameter that scales the input to the final softmax. A high temperature flattens the distribution from which characters are sampled, increasing the probability of extracting less likely characters:

Out[10]= | |

Decreasing the temperature sharpens the peaks of the sampling distribution, further decreasing the probability of extracting less likely characters:

Out[11]= | |

Very high temperature settings are equivalent to random sampling:

Out[12]= | |

Very low temperature settings are equivalent to always picking the character with maximum probability. It is typical for sampling to “get stuck in a loop”:

Out[13]= | |

### Inspection of predictions

Define a function that takes a string and guesses the next character as it reads, showing the predictions in a grid. The input string is shown on top, while the top 5 predictions are aligned below each character, starting from more likely guesses. For each prediction, the intensity of the color is proportional to the probability:

Out[15]= | |

### Net information

Inspect the sizes of all arrays in the net:

Out[16]= | |

Obtain the total number of parameters:

Out[17]= | |

Obtain the layer type counts:

Out[18]= | |

Display the summary graphic:

Out[19]= | |

### Export to MXNet

Export the net into a format that can be opened in MXNet:

Out[20]= | |

Export also creates a net.params file containing parameters:

Out[21]= | |

Get the size of the parameter file:

Out[22]= | |

The size is similar to the byte count of the resource object:

Out[23]= | |