React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.
Table of Contents
React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.
Table of Contents
import React, {useState} from 'react'; | |
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native'; | |
const App = () => { | |
const [count, setCount] = useState(0); | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.title}>Hello from {'\n'}React Native Web!</Text> | |
<TouchableOpacity | |
onPress={() => setCount(count + 1)} |
{ | |
"scripts": { | |
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min", | |
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015", | |
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm", | |
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs", | |
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js", | |
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz", | |
} | |
} |
enum keyCodes { | |
BACKSPACE: 8, | |
TAB: 9, | |
ENTER: 13, | |
SHIFT: 16, | |
CTRL: 17, | |
ALT: 18, | |
PAUSE: 19, | |
CAPS_LOCK: 20, | |
ESCAPE: 27, |
/** | |
* number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP. | |
* It formats a number to a string with grouped thousands, with custom seperator and custom decimal point | |
* @param {number} number - number to format | |
* @param {number} [decimals=0] - (optional) count of decimals to show | |
* @param {string} [decPoint=.] - (optional) decimal point | |
* @param {string} [thousandsSep=,] - (optional) thousands seperator | |
* @author Felix Leupold <[email protected]> | |
*/ | |
function number_format(number, decimals, decPoint, thousandsSep) { |
# This small script shows how to use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions | |
# Script installs allennlp default model | |
# Important: Install allennlp form source and replace the spacy requirement with spacy-nightly in the requirements.txt | |
# Developed for SpaCy 2.0.0a18 | |
from allennlp.commands import DEFAULT_MODELS | |
from allennlp.common.file_utils import cached_path | |
from allennlp.service.predictors import SemanticRoleLabelerPredictor | |
from allennlp.models.archival import load_archive |
import threading | |
import time | |
class ThreadingExample(object): | |
""" Threading example class | |
The run() method will be started and it will run in the background | |
until the application exits. | |
""" |
def dot_product(x, kernel): | |
""" | |
Wrapper for dot product operation, in order to be compatible with both | |
Theano and Tensorflow | |
Args: | |
x (): input | |
kernel (): weights | |
Returns: | |
""" | |
if K.backend() == 'tensorflow': |
class AttentionLSTM(LSTM): | |
"""LSTM with attention mechanism | |
This is an LSTM incorporating an attention mechanism into its hidden states. | |
Currently, the context vector calculated from the attended vector is fed | |
into the model's internal states, closely following the model by Xu et al. | |
(2016, Sec. 3.1.2), using a soft attention model following | |
Bahdanau et al. (2014). | |
The layer expects two inputs instead of the usual one: |
class AttentionWithContext(Layer): | |
""" | |
Attention operation, with a context/query vector, for temporal data. | |
Supports Masking. | |
Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] | |
"Hierarchical Attention Networks for Document Classification" | |
by using a context vector to assist the attention | |
# Input shape | |
3D tensor with shape: `(samples, steps, features)`. | |
# Output shape |