MCPcopy Create free account
hub / github.com/apache/singa / convert

Function convert

examples/rnn/char_rnn.py:146–161  ·  view source on GitHub ↗

convert a batch of data into a sequence of input tensors

(batch,
            batch_size,
            seq_length,
            vocab_size,
            dev,
            inputs=None,
            labels=None)

Source from the content-addressed store, hash-verified

144
145
146def convert(batch,
147 batch_size,
148 seq_length,
149 vocab_size,
150 dev,
151 inputs=None,
152 labels=None):
153 '''convert a batch of data into a sequence of input tensors'''
154 y = batch[:, 1:]
155 x1 = batch[:, :seq_length]
156 x = np.zeros((batch_size, seq_length, vocab_size), dtype=np.float32)
157 for b in range(batch_size):
158 for t in range(seq_length):
159 c = x1[b, t]
160 x[b, t, c] = 1
161 return numpy2tensors(x, y, dev, inputs, labels)
162
163
164def sample(model, data, dev, nsamples=100, use_max=False):

Callers 2

evaluateFunction · 0.70
trainFunction · 0.70

Calls 1

numpy2tensorsFunction · 0.70

Tested by

no test coverage detected