/** * Returns the number of times the Jetpack Credentials Banner was viewed. * * @param {object} state Global state tree * @returns {number} Number of times the banner was viewed */ function getJetpackCredentialsBannerViewCount( state: DefaultRootState ): number { const preference = getJetpackCredentialsBannerPreference( state ); return preference.filter( ( { type } ) => type === 'view' ).length; }
describe('relu', () => { it('calls forwardFn', () => { const equation = new Equation(); const input = fourSquareMatrix(1); equation.add(input, fourSquareMatrix(1)); expect(equation.states.length).toBe(1); jest.spyOn(equation.states[0], 'forwardFn'); equation.runIndex(); expect(equation.states[0].forwardFn).toBeCalled(); }); });
it('sets up equations for length of input(3), output(1) plus count plus 1 for internal of 0', () => { const net = new RNNTimeStep({ inputSize: 1, hiddenLayers: [1], outputSize: 1, }); net.initialize(); net.bindEquation(); expect(net.model.equations.length).toBe(1); net.trainInputOutput({ input: [1, 2, 3], output: [4] }); expect(net.model.equations.length).toBe(4); });
/** * * @returns boolean */ get isRunnable() { if (this.model.equations.length === 0) { console.error(`No equations bound, did you run train()?`); return false; } return true; }
validateForm() { const formData = this.formRef.getFormData(); const errors = Object.keys(this.validatedFields).reduce((memo, fieldName) => { const fieldValue = formData[fieldName]; if (!this.validatedFields[fieldName].isValid(fieldValue)) { memo[fieldName] = this.validatedFields[fieldName].error; } return memo; }, {}); return {errors, isValid: !Object.keys(errors).length}; }
componentDidUpdate() { this.markerArray = []; this.displayHouses(); this.displayUsers(); if (this.markerArray.length >= 1) { const group = leaflet.featureGroup(this.markerArray); this.leafletMap.fitBounds(group.getBounds(), { padding: [150, 150] }); } }
sendDefferedMethodCall() { if (this.pendingRequests.length > 0) { this.isRequestPending = true; const nextRequest = this.pendingRequests.shift(); this.sendMethodCall(nextRequest.methodName, nextRequest.parameters) .then(nextRequest.resolve) .catch(nextRequest.reject); } }
save() { if (this.commands.length === 0) { return; } const historyFile = path.join(global.output_dir, 'cli-history'); const commandSnippet = `\n\n<<< Recorded commands on ${new Date()}\n${this.commands.join('\n')}`; fs.appendFileSync(historyFile, commandSnippet); output.print(colors.yellow(` Commands have been saved to ${historyFile}`)); this.commands = []; }
static addKeys(value, table) { if (Array.isArray(value)) return; table = table || {}; let i = Object.keys(table).length; for (const p in value) { if (!value.hasOwnProperty(p)) continue; if (table.hasOwnProperty(p)) continue; table[p] = i++; } return table; }
/** * @description Return the number of users in this instance. * @returns {number} Return the number of users. * @example * const nbOfUser = user.getUserCount(); */ function getUserCount() { return Object.keys(this.stateManager.state.user).length; }
initializeDeep() { const layers = this._connectLayersDeep(); for (let i = 0; i < layers.length; i++) { const layer = layers[i]; layer.reuseKernels(this._layerSets[0][i]); } this._layerSets.push(layers); }
it('sets up equations for length of input(3), output(2) plus count plus 1 for internal of 0', () => { const net = new RNNTimeStep({ inputSize: 1, hiddenLayers: [1], outputSize: 1, }); net.initialize(); net.bindEquation(); expect(net.model.equations.length).toBe(1); net.trainInputOutput({ input: [1, 2, 3], output: [4, 5] }); expect(net.model.equations.length).toBe(5); });