"L'errore a destra (la variante a colori) costituisce un enorme miglioramento grazie alla concisa rappresentazione in rosso del messaggio critico e alla rappresentazione in blu del widget interessato".
"Nascondere l'intero oggetto Widget riduce il disordine (nella variante con puntini di sospensione), facilitando la ricerca del motivo dell'errore".
"L'opzione B (la variante con spazi) è molto più facile da analizzare. Le sezioni sono suddivise in modo chiaro, quindi è facile capire cosa scremare e come spostarsi da una sezione all'altra".
python pack_nbrs.py --max_nbrs=5 \ labeled_data.tfr \ unlabeled_data.tfr \ graph.tsv \ merged_examples.tfr
import neural_structured_learning as nsl# Create a custom model — sequential, functional, or subclass. base_model = tf.keras.Sequential(…)# Wrap the custom model with graph regularization. graph_config = nsl.configs.GraphRegConfig( neighbor_config=nsl.configs.GraphNeighborConfig(max_neighbors=1)) graph_model = nsl.keras.GraphRegularization(base_model, graph_config)# Compile, train, and evaluate. graph_model.compile(optimizer=’adam’, loss=tf.keras.losses.SparseCategoricalCrossentropy(), metrics=[‘accuracy’]) graph_model.fit(train_dataset, epochs=5) graph_model.evaluate(test_dataset)
import neural_structured_learning as nsl# Create a base model — sequential, functional, or subclass. model = tf.keras.Sequential(…)# Wrap the model with adversarial regularization. adv_config = nsl.configs.make_adv_reg_config(multiplier=0.2, adv_step_size=0.05) adv_model = nsl.keras.AdversarialRegularization(model, adv_config)# Compile, train, and evaluate. adv_model.compile(optimizer=’adam’, loss=’sparse_categorical_crossentropy’, metrics=[‘accuracy’]) adv_model.fit({‘feature’: x_train, ‘label’: y_train}, epochs=5) adv_model.evaluate({‘feature’: x_test, ‘label’: y_test})
// BLOCKING remoteConfig = RemoteConfig.remoteConfig() // Fetch with a completion handler. remoteConfig.fetch { status, error in if status == .success { remoteConfig.activateFetched() let value = remoteConfig[“myKey”]; } }
// Non-blocking initialization. remoteConfig = RemoteConfig.remoteConfig() remoteConfig.fetchAndActivate { (status, error) in if status == .successFetchedFromRemote || status ==.successUsingPreFetchedData { let value = remoteConfig[“myKey”]; } }
// BLOCKING FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance(); frc.fetch() .addOnSuccessListener(new …<>() { frc.activateFetched(); readFrcValues(); }); void readFrcValues() { value = frc.getInteger(“myKey”); }
// Non-blocking initialization. // Loads values from disk asynchronously. FirebaseRemoteConfig frc = FirebaseRemoteConfig.getInstance(); frc.fetchAndActivate().addOnSuccessListener((unusedVoid) -> readFrcValues()); void readFrcValues() { value = frc.getInteger(“myKey”); }
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder() .setMinimumFetchIntervalInSeconds(fetchRefreshRate) .setFetchTimeoutInSeconds(fetchTimeout) .build(); mFirebaseRemoteConfig.setConfigSettings(configSettings);
configSettings
let remoteConfigSettings = RemoteConfigSettings() remoteConfigSettings.minimumFetchInterval = 1200 remoteConfigSettings.fetchTimeout = 3 remoteConfig.configSettings = remoteConfigSettings
MinimumFetchIntervalInSeconds
... i dati di associazione alla tua UI devono essere stateless. Tuttavia, le animazioni sono stateful.
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ data class LoginUiModel( val submitEnabled: Boolean, val loginInProgress: Boolean ) … setVisibility(login, !uiModel.loginInProgress) setVisibility(progress, uiModel.loginInProgress) … fun setVisibility(view: View, visible: Boolean) { view.visibility = if (visible) View.VISIBLE else View.GONE }
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ fun animateVisibility(view: View, visible: Boolean) { view.visibility = View.VISIBLE if (visible) { ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f).start() } else { ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f).apply { doOnEnd { view.visibility = View.GONE } }.start() } }
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ - ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f).start() + ObjectAnimator.ofFloat(view, View.ALPHA, 1f).start()
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ fun animateVisibility(view: View, visible: Boolean) { + val targetAlpha = if (visible) 1f else 0f + if (view.alpha == targetAlpha) return
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ - val anim = ObjectAnimator.ofFloat(view, View.ALPHA, targetAlpha) - if (!visible) { - anim.doOnEnd { view.visibility = View.GONE } - } + val anim = view.animate().alpha(targetAlpha) + if (!visible) { + anim.withEndAction { view.visibility = View.GONE } + }
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ fun View.spring( property: ViewProperty ): SpringAnimation { val key = getKey(property) var springAnim = getTag(key) as? SpringAnimation? if (springAnim == null) { springAnim = SpringAnimation(this, property) setTag(key, springAnim) } return springAnim }
/* Copyright 2019 Google LLC. SPDX-License-Identifier: Apache-2.0 */ - val anim = view.animate().alpha(targetAlpha) + val spring = view.spring(SpringAnimation.ALPHA) + spring.animateToFinalPosition(targetAlpha)