(config: InputConfig)
| 173 | } |
| 174 | |
| 175 | export function Input(config: InputConfig): SymbolicTensor { |
| 176 | if (config.batchShape == null && config.shape == null) { |
| 177 | throw new Error( |
| 178 | 'Please provide to Input either a `shape`' + |
| 179 | ' or a `batchShape` argument. Note that ' + |
| 180 | '`shape` does not include the batch ' + |
| 181 | 'dimension.'); |
| 182 | } |
| 183 | if (config.batchShape != null && config.shape != null) { |
| 184 | // TODO(michaelterry): Backport to PyKeras. |
| 185 | throw new ValueError( |
| 186 | 'Please provide either a `shape` or `batchShape` ' + |
| 187 | 'argument to Input, but not both.'); |
| 188 | } |
| 189 | let batchShape = config.batchShape; |
| 190 | if (config.shape != null && batchShape == null) { |
| 191 | batchShape = [null].concat(config.shape); |
| 192 | } |
| 193 | |
| 194 | let dtype = config.dtype; |
| 195 | if (dtype == null) { |
| 196 | dtype = 'float32'; |
| 197 | } |
| 198 | |
| 199 | const inputLayer = new InputLayer({ |
| 200 | batchInputShape: batchShape, |
| 201 | name: config.name, |
| 202 | dtype, |
| 203 | sparse: config.sparse |
| 204 | }); |
| 205 | |
| 206 | const outputs = inputLayer.inboundNodes[0].outputTensors; |
| 207 | return outputs[0]; |
| 208 | } |
no test coverage detected
searching dependent graphs…