问:
Devops Pull Request workflow validations
We are using Azure devops with the workflow for each task as:

Task branch to Release branch

Then Release branch to master

The reviewer will approve each pull request.

However, a user creating a PR can also create one from task branch directly to master.

Is there any way, by policies/validations that the system can prevent creation of the PR itself, which is from task to master.

答:
Currently azure devops doesnot have the policies/validations to prevent creating a pr which is task to master.

However, there is workaround to prevent merging the PR which is task to master.

You can create a pipeline with a script task to check the source branch of the PR. See below:

```<code>$sourceBranch = "$(System.PullRequest.SourceBranch)"

if($sourceBranch -ne "refs/heads/release")
{
    exit 1
}
</code>```

For example add a powershell task with above script. The script will check if the PR source branch is release branch, and fail the pipeline if it is not.

Then you can add above pipeline to the branch policy of master branch. See below:

Then any PR which is not release to master will fail to be validated and cannot be completed. (But it still cannot prevent creating a PR from test to master)

You can also click here to submit a feature request(Click Suggest a feature and select Azure Devops. ) to Microsoft development team. Hopefully they will consider adding this feature in the future.

See below screenshot from my test pipeline.

Body:
Currently azure devops doesnot have the policies/validations to prevent creating a pr which is task to master.

However, there is workaround to prevent merging the PR which is task to master.

You can create a pipeline with a script task to check the source branch of the PR. See below:

$sourceBranch = "$(System.PullRequest.SourceBranch)"

if($sourceBranch -ne "refs/heads/release")
{
    exit 1
}

For example add a powershell task with above script. The script will check if the PR source branch is release branch, and fail the pipeline if it is not.

Then you can add above pipeline to the branch policy of master branch. See below:

Then any PR which is not release to master will fail to be validated and cannot be completed. (But it still cannot prevent creating a PR from test to master)

You can also click here to submit a feature request(Click Suggest a feature and select Azure Devops. ) to Microsoft development team. Hopefully they will consider adding this feature in the future.

See below screenshot from my test pipeline.


来源: stackexchange

问:
ValueError: Arguments and signature arguments do not match. got: 13, expected: 14
I am trying to generate confidence intervals my keras model's predictions following the logic outlined in here: How to calculate prediction uncertainty using Keras?, and here: https://medium.com/hal24k-techblog/how-to-generate-neural-network-confidence-intervals-with-keras-e4c0b78ebbdf

I have searched on the Keras github issues page for similar issues which suggested I was using the wrong method to instantiate a new model with a predefined config, however despite changing my code from Model.from_config() to tf.keras.Sequential.from_config() the issue still persists.

Code as per below:

```<code># Model
def mlp_model():
  model = tf.keras.Sequential([
    tf.keras.layers.Dense(3, input_dim = 3,
                          kernel_initializer = 'glorot_uniform',
                          activation = 'elu'),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.001)),
    tf.keras.layers.GaussianNoise(0.3),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dense(160,
                          activation = 'relu',
                          kernel_regularizer = regularizers.l2(0.004)), #128 for unscaled
    tf.keras.layers.Dense(1)
  ])

  model.compile(optimizer = opt,
                loss = root_mean_squared_error,
                metrics=['mean_squared_error',
                         'mean_absolute_error',
                         root_mean_squared_error])
  return model

# fit model
model = mlp_model()
model_history = model.fit(train_batch,
                          validation_data = test_batch,
                          epochs = 100,
                          shuffle = False,
                          callbacks = [early_stop,
                                       model_checkpoint,
                                       tensorboard_callback])

# Create dropout func
def create_dropout_predict_function(model, dropout):

    # Load the config of the original model
    conf = model.get_config()

    # Add the specified dropout to all layers
    for layer in conf['layers']:
        # Dropout layers
        if layer["class_name"]=="Dropout":
            layer["config"]["rate"] = dropout

    # Using Functional API
    model_dropout = tf.keras.Sequential.from_config(conf)
    model_dropout.set_weights(model.get_weights())

    # Predict with dropout
    predict_with_dropout = K.function(model_dropout.inputs+[K.learning_phase()], model_dropout.outputs)

    return predict_with_dropout

# Create preds with dropout
dropout = 0.5
num_iter = 20
num_samples = len(forecast_ahead_df)

predict_with_dropout = create_dropout_predict_function(model, dropout)

predictions = np.zeros((num_samples, num_iter))

for i in range(num_iter):
    predictions[:, i] = predict_with_dropout(forecast_batch)
</code>```

Any help much appreciated, and a big thank you to all that have helped so far.

答:
I'm on tensorflow version 2.0.0 and no GPU, but hopefully this still fixes the problems. It seems like you are only feeding your network input data (X), but no respond data (Y). So there is nothing for the model to learn. I only added the response data Y in model.fit().

I have used your code and trained on the this dataset. The following code worked for me in tensorflow 2.0.0, see comment for changes:

```<code>import tensorflow as tf
print(tf.__version__)
from tensorflow.keras import regularizers
import numpy as np

# load pima indians dataset
dataset = np.loadtxt("/content/pima-indians-diabetes.csv", delimiter=",")

# split into input (X) and output (Y) variables
X = dataset[:,0:8]
Y = dataset[:,8]

# Changed the Input Dimenseion to input_dim = 8
def mlp_model():
  model = tf.keras.Sequential([
    tf.keras.layers.Dense(3, input_dim = 8,
                          kernel_initializer = 'glorot_uniform',
                          activation = 'elu'),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.001)),
    tf.keras.layers.GaussianNoise(0.3),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dense(160,
                          activation = 'relu',
                          kernel_regularizer = regularizers.l2(0.004)), #128 for unscaled
    tf.keras.layers.Dense(1)
  ])

  # Removed unavailable functions and used the tensorflow available optimizer, loss and metrics
  model.compile(optimizer = 'adam',
                loss = 'binary_crossentropy',
                metrics=['mean_squared_error',
                         'mean_absolute_error'])
  return model

# fit model
model = mlp_model()
# Added the response variable Y
model_history = model.fit(X, Y,
                          epochs = 100)
</code>```

Output -

```<code>2.0.0
Train on 768 samples
Epoch 1/100
768/768 [==============================] - 1s 1ms/sample - loss: 8.1430 - mean_squared_error: 105.6280 - mean_absolute_error: 8.0280
Epoch 2/100
768/768 [==============================] - 0s 90us/sample - loss: 11.3845 - mean_squared_error: 819.4331 - mean_absolute_error: 25.4116
Epoch 3/100
768/768 [==============================] - 0s 96us/sample - loss: 11.2765 - mean_squared_error: 1185.4595 - mean_absolute_error: 30.9923
Epoch 4/100
768/768 [==============================] - 0s 90us/sample - loss: 11.1805 - mean_squared_error: 1230.1932 - mean_absolute_error: 31.5183
Epoch 5/100
768/768 [==============================] - 0s 88us/sample - loss: 11.0962 - mean_squared_error: 1161.8567 - mean_absolute_error: 30.6245
Epoch 6/100
768/768 [==============================] - 0s 88us/sample - loss: 11.0217 - mean_squared_error: 1129.4146 - mean_absolute_error: 30.2203
Epoch 7/100
768/768 [==============================] - 0s 91us/sample - loss: 10.9550 - mean_squared_error: 1097.7333 - mean_absolute_error: 29.7042
Epoch 8/100
768/768 [==============================] - 0s 91us/sample - loss: 10.8947 - mean_squared_error: 1066.2788 - mean_absolute_error: 29.1740
Epoch 9/100
768/768 [==============================] - 0s 89us/sample - loss: 10.8396 - mean_squared_error: 1035.1652 - mean_absolute_error: 28.6741
Epoch 10/100
768/768 [==============================] - 0s 86us/sample - loss: 10.7892 - mean_squared_error: 987.1348 - mean_absolute_error: 28.0417
Epoch 11/100
768/768 [==============================] - 0s 90us/sample - loss: 10.7427 - mean_squared_error: 947.6363 - mean_absolute_error: 27.4314
Epoch 12/100
768/768 [==============================] - 0s 88us/sample - loss: 10.6997 - mean_squared_error: 891.5195 - mean_absolute_error: 26.5769
Epoch 13/100
768/768 [==============================] - 0s 88us/sample - loss: 10.6599 - mean_squared_error: 868.7969 - mean_absolute_error: 26.1633
Epoch 14/100
768/768 [==============================] - 0s 94us/sample - loss: 10.6230 - mean_squared_error: 818.0642 - mean_absolute_error: 25.2891
Epoch 15/100
768/768 [==============================] - 0s 92us/sample - loss: 10.5886 - mean_squared_error: 772.1309 - mean_absolute_error: 24.7540
Epoch 16/100
768/768 [==============================] - 0s 87us/sample - loss: 10.5567 - mean_squared_error: 745.1671 - mean_absolute_error: 24.1730
Epoch 17/100
768/768 [==============================] - 0s 85us/sample - loss: 10.5269 - mean_squared_error: 691.4273 - mean_absolute_error: 23.3115
Epoch 18/100
768/768 [==============================] - 0s 109us/sample - loss: 10.4991 - mean_squared_error: 651.1308 - mean_absolute_error: 22.6068
Epoch 19/100
768/768 [==============================] - 0s 87us/sample - loss: 10.4732 - mean_squared_error: 634.8137 - mean_absolute_error: 22.2203
Epoch 20/100
768/768 [==============================] - 0s 85us/sample - loss: 10.4489 - mean_squared_error: 600.7214 - mean_absolute_error: 21.5552
Epoch 21/100
768/768 [==============================] - 0s 87us/sample - loss: 10.4262 - mean_squared_error: 557.6275 - mean_absolute_error: 20.9041
Epoch 22/100
768/768 [==============================] - 0s 92us/sample - loss: 10.4050 - mean_squared_error: 533.1421 - mean_absolute_error: 20.3297
Epoch 23/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3850 - mean_squared_error: 528.4443 - mean_absolute_error: 19.9225
Epoch 24/100
768/768 [==============================] - 0s 84us/sample - loss: 10.3663 - mean_squared_error: 488.9399 - mean_absolute_error: 19.3189
Epoch 25/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3487 - mean_squared_error: 448.7306 - mean_absolute_error: 18.5765
Epoch 26/100
768/768 [==============================] - 0s 87us/sample - loss: 10.3322 - mean_squared_error: 425.1384 - mean_absolute_error: 18.0467
Epoch 27/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3166 - mean_squared_error: 390.8499 - mean_absolute_error: 17.3933
Epoch 28/100
768/768 [==============================] - 0s 91us/sample - loss: 10.3019 - mean_squared_error: 373.9980 - mean_absolute_error: 16.8805
Epoch 29/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2881 - mean_squared_error: 358.0975 - mean_absolute_error: 16.4838
Epoch 30/100
768/768 [==============================] - 0s 89us/sample - loss: 10.2750 - mean_squared_error: 330.0729 - mean_absolute_error: 15.8146
Epoch 31/100
768/768 [==============================] - 0s 94us/sample - loss: 10.2627 - mean_squared_error: 304.5206 - mean_absolute_error: 15.1873
Epoch 32/100
768/768 [==============================] - 0s 96us/sample - loss: 10.2510 - mean_squared_error: 284.8553 - mean_absolute_error: 14.7007
Epoch 33/100
768/768 [==============================] - 0s 85us/sample - loss: 10.2400 - mean_squared_error: 269.9680 - mean_absolute_error: 14.2868
Epoch 34/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2295 - mean_squared_error: 258.1902 - mean_absolute_error: 13.8228
Epoch 35/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2196 - mean_squared_error: 233.8299 - mean_absolute_error: 13.2536
Epoch 36/100
768/768 [==============================] - 0s 90us/sample - loss: 10.2102 - mean_squared_error: 226.0575 - mean_absolute_error: 12.8807
Epoch 37/100
768/768 [==============================] - 0s 90us/sample - loss: 10.2013 - mean_squared_error: 208.6756 - mean_absolute_error: 12.4301
Epoch 38/100
768/768 [==============================] - 0s 85us/sample - loss: 10.1928 - mean_squared_error: 190.1977 - mean_absolute_error: 11.8795
Epoch 39/100
768/768 [==============================] - 0s 92us/sample - loss: 10.1847 - mean_squared_error: 179.3409 - mean_absolute_error: 11.5069
Epoch 40/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1770 - mean_squared_error: 164.0748 - mean_absolute_error: 11.0245
Epoch 41/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1697 - mean_squared_error: 154.7774 - mean_absolute_error: 10.5896
Epoch 42/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1627 - mean_squared_error: 138.8940 - mean_absolute_error: 10.1659
Epoch 43/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1560 - mean_squared_error: 130.8000 - mean_absolute_error: 9.8535
Epoch 44/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1496 - mean_squared_error: 120.8661 - mean_absolute_error: 9.4153
Epoch 45/100
768/768 [==============================] - 0s 84us/sample - loss: 10.1435 - mean_squared_error: 109.2852 - mean_absolute_error: 9.0433
Epoch 46/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1377 - mean_squared_error: 103.8257 - mean_absolute_error: 8.6843
Epoch 47/100
768/768 [==============================] - 0s 93us/sample - loss: 10.1322 - mean_squared_error: 96.0696 - mean_absolute_error: 8.3516
Epoch 48/100
768/768 [==============================] - 0s 95us/sample - loss: 10.1268 - mean_squared_error: 87.2735 - mean_absolute_error: 7.9551
Epoch 49/100
768/768 [==============================] - 0s 84us/sample - loss: 10.1217 - mean_squared_error: 78.5033 - mean_absolute_error: 7.5730
Epoch 50/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1168 - mean_squared_error: 73.8310 - mean_absolute_error: 7.2905
Epoch 51/100
768/768 [==============================] - 0s 96us/sample - loss: 10.1121 - mean_squared_error: 65.5390 - mean_absolute_error: 6.9333
Epoch 52/100
768/768 [==============================] - 0s 94us/sample - loss: 10.1076 - mean_squared_error: 62.0906 - mean_absolute_error: 6.6996
Epoch 53/100
768/768 [==============================] - 0s 93us/sample - loss: 10.1033 - mean_squared_error: 54.6800 - mean_absolute_error: 6.3188
Epoch 54/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0991 - mean_squared_error: 49.5616 - mean_absolute_error: 6.0299
Epoch 55/100
768/768 [==============================] - 0s 91us/sample - loss: 10.0951 - mean_squared_error: 46.1167 - mean_absolute_error: 5.7707
Epoch 56/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0913 - mean_squared_error: 41.3520 - mean_absolute_error: 5.4638
Epoch 57/100
768/768 [==============================] - 0s 98us/sample - loss: 10.0876 - mean_squared_error: 37.7623 - mean_absolute_error: 5.2175
Epoch 58/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0840 - mean_squared_error: 35.0457 - mean_absolute_error: 4.9933
Epoch 59/100
768/768 [==============================] - 0s 85us/sample - loss: 10.0806 - mean_squared_error: 31.3319 - mean_absolute_error: 4.6894
Epoch 60/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0773 - mean_squared_error: 28.8361 - mean_absolute_error: 4.5389
Epoch 61/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0741 - mean_squared_error: 25.4872 - mean_absolute_error: 4.2417
Epoch 62/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0710 - mean_squared_error: 23.8177 - mean_absolute_error: 4.1007
Epoch 63/100
768/768 [==============================] - 0s 84us/sample - loss: 7.0914 - mean_squared_error: 101.6586 - mean_absolute_error: 7.4064
Epoch 64/100
768/768 [==============================] - 0s 87us/sample - loss: 5.5155 - mean_squared_error: 457.9014 - mean_absolute_error: 18.0251
Epoch 65/100
768/768 [==============================] - 0s 88us/sample - loss: 5.5088 - mean_squared_error: 392.7791 - mean_absolute_error: 16.7004
Epoch 66/100
768/768 [==============================] - 0s 98us/sample - loss: 5.5000 - mean_squared_error: 272.5681 - mean_absolute_error: 13.7357
Epoch 67/100
768/768 [==============================] - 0s 86us/sample - loss: 5.4928 - mean_squared_error: 188.3301 - mean_absolute_error: 11.4254
Epoch 68/100
768/768 [==============================] - 0s 84us/sample - loss: 5.4869 - mean_squared_error: 144.7060 - mean_absolute_error: 10.0285
Epoch 69/100
768/768 [==============================] - 0s 83us/sample - loss: 5.4821 - mean_squared_error: 160.2795 - mean_absolute_error: 10.7119
Epoch 70/100
768/768 [==============================] - 0s 94us/sample - loss: 5.4772 - mean_squared_error: 114.1624 - mean_absolute_error: 9.0611
Epoch 71/100
768/768 [==============================] - 0s 91us/sample - loss: 5.4729 - mean_squared_error: 81.6616 - mean_absolute_error: 7.5558
Epoch 72/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4690 - mean_squared_error: 58.3508 - mean_absolute_error: 6.3955
Epoch 73/100
768/768 [==============================] - 0s 87us/sample - loss: 5.4654 - mean_squared_error: 44.2179 - mean_absolute_error: 5.5208
Epoch 74/100
768/768 [==============================] - 0s 91us/sample - loss: 5.4621 - mean_squared_error: 33.7123 - mean_absolute_error: 4.7988
Epoch 75/100
768/768 [==============================] - 0s 97us/sample - loss: 5.4590 - mean_squared_error: 26.4150 - mean_absolute_error: 4.2291
Epoch 76/100
768/768 [==============================] - 0s 86us/sample - loss: 5.4561 - mean_squared_error: 21.0693 - mean_absolute_error: 3.7517
Epoch 77/100
768/768 [==============================] - 0s 82us/sample - loss: 5.4533 - mean_squared_error: 16.6050 - mean_absolute_error: 3.3334
Epoch 78/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4507 - mean_squared_error: 13.3761 - mean_absolute_error: 2.9838
Epoch 79/100
768/768 [==============================] - 0s 94us/sample - loss: 5.4482 - mean_squared_error: 10.6811 - mean_absolute_error: 2.6628
Epoch 80/100
768/768 [==============================] - 0s 90us/sample - loss: 5.4459 - mean_squared_error: 9.5541 - mean_absolute_error: 2.4669
Epoch 81/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4438 - mean_squared_error: 11.0352 - mean_absolute_error: 2.7847
Epoch 82/100
768/768 [==============================] - 0s 83us/sample - loss: 5.4416 - mean_squared_error: 8.8724 - mean_absolute_error: 2.4634
Epoch 83/100
768/768 [==============================] - 0s 96us/sample - loss: 5.4395 - mean_squared_error: 7.0467 - mean_absolute_error: 2.1836
Epoch 84/100
768/768 [==============================] - 0s 86us/sample - loss: 8.0375 - mean_squared_error: 36.5165 - mean_absolute_error: 4.8413
Epoch 85/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0764 - mean_squared_error: 126.9524 - mean_absolute_error: 10.2454
Epoch 86/100
768/768 [==============================] - 0s 87us/sample - loss: 10.0705 - mean_squared_error: 121.3718 - mean_absolute_error: 9.9911
Epoch 87/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0631 - mean_squared_error: 96.0288 - mean_absolute_error: 8.9118
Epoch 88/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0572 - mean_squared_error: 74.3836 - mean_absolute_error: 7.9054
Epoch 89/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0524 - mean_squared_error: 62.7223 - mean_absolute_error: 7.1927
Epoch 90/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0484 - mean_squared_error: 48.8116 - mean_absolute_error: 6.4094
Epoch 91/100
768/768 [==============================] - 0s 93us/sample - loss: 10.0448 - mean_squared_error: 39.1147 - mean_absolute_error: 5.7639
Epoch 92/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0417 - mean_squared_error: 32.7087 - mean_absolute_error: 5.2643
Epoch 93/100
768/768 [==============================] - 0s 85us/sample - loss: 10.0389 - mean_squared_error: 26.4908 - mean_absolute_error: 4.7354
Epoch 94/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0363 - mean_squared_error: 21.6876 - mean_absolute_error: 4.2937
Epoch 95/100
768/768 [==============================] - 0s 89us/sample - loss: 10.0340 - mean_squared_error: 17.6745 - mean_absolute_error: 3.8886
Epoch 96/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0318 - mean_squared_error: 14.5234 - mean_absolute_error: 3.5385
Epoch 97/100
768/768 [==============================] - 0s 93us/sample - loss: 10.0298 - mean_squared_error: 12.3609 - mean_absolute_error: 3.2538
Epoch 98/100
768/768 [==============================] - 0s 91us/sample - loss: 10.0279 - mean_squared_error: 10.0023 - mean_absolute_error: 2.9435
Epoch 99/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0261 - mean_squared_error: 8.6058 - mean_absolute_error: 2.7176
Epoch 100/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0244 - mean_squared_error: 7.0987 - mean_absolute_error: 2.4628
</code>```

Hope this answers your question. Happy Learning.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to generate confidence intervals my keras model's predictions following the logic outlined in here: How to calculate prediction uncertainty using Keras?, and here: https://medium.com/hal24k-techblog/how-to-generate-neural-network-confidence-intervals-with-keras-e4c0b78ebbdf

I have searched on the Keras github issues page for similar issues which suggested I was using the wrong method to instantiate a new model with a predefined config, however despite changing my code from Model.from_config() to tf.keras.Sequential.from_config() the issue still persists.

Code as per below:

# Model
def mlp_model():
  model = tf.keras.Sequential([
    tf.keras.layers.Dense(3, input_dim = 3,
                          kernel_initializer = 'glorot_uniform',
                          activation = 'elu'),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.001)),
    tf.keras.layers.GaussianNoise(0.3),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dense(160,
                          activation = 'relu',
                          kernel_regularizer = regularizers.l2(0.004)), #128 for unscaled
    tf.keras.layers.Dense(1)
  ])

  model.compile(optimizer = opt,
                loss = root_mean_squared_error,
                metrics=['mean_squared_error',
                         'mean_absolute_error',
                         root_mean_squared_error])
  return model

# fit model
model = mlp_model()
model_history = model.fit(train_batch,
                          validation_data = test_batch,
                          epochs = 100,
                          shuffle = False,
                          callbacks = [early_stop,
                                       model_checkpoint,
                                       tensorboard_callback])

# Create dropout func
def create_dropout_predict_function(model, dropout):

    # Load the config of the original model
    conf = model.get_config()

    # Add the specified dropout to all layers
    for layer in conf['layers']:
        # Dropout layers
        if layer["class_name"]=="Dropout":
            layer["config"]["rate"] = dropout

    # Using Functional API
    model_dropout = tf.keras.Sequential.from_config(conf)
    model_dropout.set_weights(model.get_weights())

    # Predict with dropout
    predict_with_dropout = K.function(model_dropout.inputs+[K.learning_phase()], model_dropout.outputs)

    return predict_with_dropout

# Create preds with dropout
dropout = 0.5
num_iter = 20
num_samples = len(forecast_ahead_df)

predict_with_dropout = create_dropout_predict_function(model, dropout)

predictions = np.zeros((num_samples, num_iter))

for i in range(num_iter):
    predictions[:, i] = predict_with_dropout(forecast_batch)

Any help much appreciated, and a big thank you to all that have helped so far.

Body:
I'm on tensorflow version 2.0.0 and no GPU, but hopefully this still fixes the problems. It seems like you are only feeding your network input data (X), but no respond data (Y). So there is nothing for the model to learn. I only added the response data Y in model.fit().

I have used your code and trained on the this dataset. The following code worked for me in tensorflow 2.0.0, see comment for changes:

import tensorflow as tf
print(tf.__version__)
from tensorflow.keras import regularizers
import numpy as np

# load pima indians dataset
dataset = np.loadtxt("/content/pima-indians-diabetes.csv", delimiter=",")

# split into input (X) and output (Y) variables
X = dataset[:,0:8]
Y = dataset[:,8]

# Changed the Input Dimenseion to input_dim = 8
def mlp_model():
  model = tf.keras.Sequential([
    tf.keras.layers.Dense(3, input_dim = 8,
                          kernel_initializer = 'glorot_uniform',
                          activation = 'elu'),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.001)),
    tf.keras.layers.GaussianNoise(0.3),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(160,
                          activation = 'elu',
                          kernel_regularizer = regularizers.l2(0.003)),
    tf.keras.layers.Dense(160,
                          activation = 'relu',
                          kernel_regularizer = regularizers.l2(0.004)), #128 for unscaled
    tf.keras.layers.Dense(1)
  ])

  # Removed unavailable functions and used the tensorflow available optimizer, loss and metrics
  model.compile(optimizer = 'adam',
                loss = 'binary_crossentropy',
                metrics=['mean_squared_error',
                         'mean_absolute_error'])
  return model

# fit model
model = mlp_model()
# Added the response variable Y
model_history = model.fit(X, Y,
                          epochs = 100)

Output -

2.0.0
Train on 768 samples
Epoch 1/100
768/768 [==============================] - 1s 1ms/sample - loss: 8.1430 - mean_squared_error: 105.6280 - mean_absolute_error: 8.0280
Epoch 2/100
768/768 [==============================] - 0s 90us/sample - loss: 11.3845 - mean_squared_error: 819.4331 - mean_absolute_error: 25.4116
Epoch 3/100
768/768 [==============================] - 0s 96us/sample - loss: 11.2765 - mean_squared_error: 1185.4595 - mean_absolute_error: 30.9923
Epoch 4/100
768/768 [==============================] - 0s 90us/sample - loss: 11.1805 - mean_squared_error: 1230.1932 - mean_absolute_error: 31.5183
Epoch 5/100
768/768 [==============================] - 0s 88us/sample - loss: 11.0962 - mean_squared_error: 1161.8567 - mean_absolute_error: 30.6245
Epoch 6/100
768/768 [==============================] - 0s 88us/sample - loss: 11.0217 - mean_squared_error: 1129.4146 - mean_absolute_error: 30.2203
Epoch 7/100
768/768 [==============================] - 0s 91us/sample - loss: 10.9550 - mean_squared_error: 1097.7333 - mean_absolute_error: 29.7042
Epoch 8/100
768/768 [==============================] - 0s 91us/sample - loss: 10.8947 - mean_squared_error: 1066.2788 - mean_absolute_error: 29.1740
Epoch 9/100
768/768 [==============================] - 0s 89us/sample - loss: 10.8396 - mean_squared_error: 1035.1652 - mean_absolute_error: 28.6741
Epoch 10/100
768/768 [==============================] - 0s 86us/sample - loss: 10.7892 - mean_squared_error: 987.1348 - mean_absolute_error: 28.0417
Epoch 11/100
768/768 [==============================] - 0s 90us/sample - loss: 10.7427 - mean_squared_error: 947.6363 - mean_absolute_error: 27.4314
Epoch 12/100
768/768 [==============================] - 0s 88us/sample - loss: 10.6997 - mean_squared_error: 891.5195 - mean_absolute_error: 26.5769
Epoch 13/100
768/768 [==============================] - 0s 88us/sample - loss: 10.6599 - mean_squared_error: 868.7969 - mean_absolute_error: 26.1633
Epoch 14/100
768/768 [==============================] - 0s 94us/sample - loss: 10.6230 - mean_squared_error: 818.0642 - mean_absolute_error: 25.2891
Epoch 15/100
768/768 [==============================] - 0s 92us/sample - loss: 10.5886 - mean_squared_error: 772.1309 - mean_absolute_error: 24.7540
Epoch 16/100
768/768 [==============================] - 0s 87us/sample - loss: 10.5567 - mean_squared_error: 745.1671 - mean_absolute_error: 24.1730
Epoch 17/100
768/768 [==============================] - 0s 85us/sample - loss: 10.5269 - mean_squared_error: 691.4273 - mean_absolute_error: 23.3115
Epoch 18/100
768/768 [==============================] - 0s 109us/sample - loss: 10.4991 - mean_squared_error: 651.1308 - mean_absolute_error: 22.6068
Epoch 19/100
768/768 [==============================] - 0s 87us/sample - loss: 10.4732 - mean_squared_error: 634.8137 - mean_absolute_error: 22.2203
Epoch 20/100
768/768 [==============================] - 0s 85us/sample - loss: 10.4489 - mean_squared_error: 600.7214 - mean_absolute_error: 21.5552
Epoch 21/100
768/768 [==============================] - 0s 87us/sample - loss: 10.4262 - mean_squared_error: 557.6275 - mean_absolute_error: 20.9041
Epoch 22/100
768/768 [==============================] - 0s 92us/sample - loss: 10.4050 - mean_squared_error: 533.1421 - mean_absolute_error: 20.3297
Epoch 23/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3850 - mean_squared_error: 528.4443 - mean_absolute_error: 19.9225
Epoch 24/100
768/768 [==============================] - 0s 84us/sample - loss: 10.3663 - mean_squared_error: 488.9399 - mean_absolute_error: 19.3189
Epoch 25/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3487 - mean_squared_error: 448.7306 - mean_absolute_error: 18.5765
Epoch 26/100
768/768 [==============================] - 0s 87us/sample - loss: 10.3322 - mean_squared_error: 425.1384 - mean_absolute_error: 18.0467
Epoch 27/100
768/768 [==============================] - 0s 89us/sample - loss: 10.3166 - mean_squared_error: 390.8499 - mean_absolute_error: 17.3933
Epoch 28/100
768/768 [==============================] - 0s 91us/sample - loss: 10.3019 - mean_squared_error: 373.9980 - mean_absolute_error: 16.8805
Epoch 29/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2881 - mean_squared_error: 358.0975 - mean_absolute_error: 16.4838
Epoch 30/100
768/768 [==============================] - 0s 89us/sample - loss: 10.2750 - mean_squared_error: 330.0729 - mean_absolute_error: 15.8146
Epoch 31/100
768/768 [==============================] - 0s 94us/sample - loss: 10.2627 - mean_squared_error: 304.5206 - mean_absolute_error: 15.1873
Epoch 32/100
768/768 [==============================] - 0s 96us/sample - loss: 10.2510 - mean_squared_error: 284.8553 - mean_absolute_error: 14.7007
Epoch 33/100
768/768 [==============================] - 0s 85us/sample - loss: 10.2400 - mean_squared_error: 269.9680 - mean_absolute_error: 14.2868
Epoch 34/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2295 - mean_squared_error: 258.1902 - mean_absolute_error: 13.8228
Epoch 35/100
768/768 [==============================] - 0s 88us/sample - loss: 10.2196 - mean_squared_error: 233.8299 - mean_absolute_error: 13.2536
Epoch 36/100
768/768 [==============================] - 0s 90us/sample - loss: 10.2102 - mean_squared_error: 226.0575 - mean_absolute_error: 12.8807
Epoch 37/100
768/768 [==============================] - 0s 90us/sample - loss: 10.2013 - mean_squared_error: 208.6756 - mean_absolute_error: 12.4301
Epoch 38/100
768/768 [==============================] - 0s 85us/sample - loss: 10.1928 - mean_squared_error: 190.1977 - mean_absolute_error: 11.8795
Epoch 39/100
768/768 [==============================] - 0s 92us/sample - loss: 10.1847 - mean_squared_error: 179.3409 - mean_absolute_error: 11.5069
Epoch 40/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1770 - mean_squared_error: 164.0748 - mean_absolute_error: 11.0245
Epoch 41/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1697 - mean_squared_error: 154.7774 - mean_absolute_error: 10.5896
Epoch 42/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1627 - mean_squared_error: 138.8940 - mean_absolute_error: 10.1659
Epoch 43/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1560 - mean_squared_error: 130.8000 - mean_absolute_error: 9.8535
Epoch 44/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1496 - mean_squared_error: 120.8661 - mean_absolute_error: 9.4153
Epoch 45/100
768/768 [==============================] - 0s 84us/sample - loss: 10.1435 - mean_squared_error: 109.2852 - mean_absolute_error: 9.0433
Epoch 46/100
768/768 [==============================] - 0s 88us/sample - loss: 10.1377 - mean_squared_error: 103.8257 - mean_absolute_error: 8.6843
Epoch 47/100
768/768 [==============================] - 0s 93us/sample - loss: 10.1322 - mean_squared_error: 96.0696 - mean_absolute_error: 8.3516
Epoch 48/100
768/768 [==============================] - 0s 95us/sample - loss: 10.1268 - mean_squared_error: 87.2735 - mean_absolute_error: 7.9551
Epoch 49/100
768/768 [==============================] - 0s 84us/sample - loss: 10.1217 - mean_squared_error: 78.5033 - mean_absolute_error: 7.5730
Epoch 50/100
768/768 [==============================] - 0s 89us/sample - loss: 10.1168 - mean_squared_error: 73.8310 - mean_absolute_error: 7.2905
Epoch 51/100
768/768 [==============================] - 0s 96us/sample - loss: 10.1121 - mean_squared_error: 65.5390 - mean_absolute_error: 6.9333
Epoch 52/100
768/768 [==============================] - 0s 94us/sample - loss: 10.1076 - mean_squared_error: 62.0906 - mean_absolute_error: 6.6996
Epoch 53/100
768/768 [==============================] - 0s 93us/sample - loss: 10.1033 - mean_squared_error: 54.6800 - mean_absolute_error: 6.3188
Epoch 54/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0991 - mean_squared_error: 49.5616 - mean_absolute_error: 6.0299
Epoch 55/100
768/768 [==============================] - 0s 91us/sample - loss: 10.0951 - mean_squared_error: 46.1167 - mean_absolute_error: 5.7707
Epoch 56/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0913 - mean_squared_error: 41.3520 - mean_absolute_error: 5.4638
Epoch 57/100
768/768 [==============================] - 0s 98us/sample - loss: 10.0876 - mean_squared_error: 37.7623 - mean_absolute_error: 5.2175
Epoch 58/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0840 - mean_squared_error: 35.0457 - mean_absolute_error: 4.9933
Epoch 59/100
768/768 [==============================] - 0s 85us/sample - loss: 10.0806 - mean_squared_error: 31.3319 - mean_absolute_error: 4.6894
Epoch 60/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0773 - mean_squared_error: 28.8361 - mean_absolute_error: 4.5389
Epoch 61/100
768/768 [==============================] - 0s 92us/sample - loss: 10.0741 - mean_squared_error: 25.4872 - mean_absolute_error: 4.2417
Epoch 62/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0710 - mean_squared_error: 23.8177 - mean_absolute_error: 4.1007
Epoch 63/100
768/768 [==============================] - 0s 84us/sample - loss: 7.0914 - mean_squared_error: 101.6586 - mean_absolute_error: 7.4064
Epoch 64/100
768/768 [==============================] - 0s 87us/sample - loss: 5.5155 - mean_squared_error: 457.9014 - mean_absolute_error: 18.0251
Epoch 65/100
768/768 [==============================] - 0s 88us/sample - loss: 5.5088 - mean_squared_error: 392.7791 - mean_absolute_error: 16.7004
Epoch 66/100
768/768 [==============================] - 0s 98us/sample - loss: 5.5000 - mean_squared_error: 272.5681 - mean_absolute_error: 13.7357
Epoch 67/100
768/768 [==============================] - 0s 86us/sample - loss: 5.4928 - mean_squared_error: 188.3301 - mean_absolute_error: 11.4254
Epoch 68/100
768/768 [==============================] - 0s 84us/sample - loss: 5.4869 - mean_squared_error: 144.7060 - mean_absolute_error: 10.0285
Epoch 69/100
768/768 [==============================] - 0s 83us/sample - loss: 5.4821 - mean_squared_error: 160.2795 - mean_absolute_error: 10.7119
Epoch 70/100
768/768 [==============================] - 0s 94us/sample - loss: 5.4772 - mean_squared_error: 114.1624 - mean_absolute_error: 9.0611
Epoch 71/100
768/768 [==============================] - 0s 91us/sample - loss: 5.4729 - mean_squared_error: 81.6616 - mean_absolute_error: 7.5558
Epoch 72/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4690 - mean_squared_error: 58.3508 - mean_absolute_error: 6.3955
Epoch 73/100
768/768 [==============================] - 0s 87us/sample - loss: 5.4654 - mean_squared_error: 44.2179 - mean_absolute_error: 5.5208
Epoch 74/100
768/768 [==============================] - 0s 91us/sample - loss: 5.4621 - mean_squared_error: 33.7123 - mean_absolute_error: 4.7988
Epoch 75/100
768/768 [==============================] - 0s 97us/sample - loss: 5.4590 - mean_squared_error: 26.4150 - mean_absolute_error: 4.2291
Epoch 76/100
768/768 [==============================] - 0s 86us/sample - loss: 5.4561 - mean_squared_error: 21.0693 - mean_absolute_error: 3.7517
Epoch 77/100
768/768 [==============================] - 0s 82us/sample - loss: 5.4533 - mean_squared_error: 16.6050 - mean_absolute_error: 3.3334
Epoch 78/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4507 - mean_squared_error: 13.3761 - mean_absolute_error: 2.9838
Epoch 79/100
768/768 [==============================] - 0s 94us/sample - loss: 5.4482 - mean_squared_error: 10.6811 - mean_absolute_error: 2.6628
Epoch 80/100
768/768 [==============================] - 0s 90us/sample - loss: 5.4459 - mean_squared_error: 9.5541 - mean_absolute_error: 2.4669
Epoch 81/100
768/768 [==============================] - 0s 88us/sample - loss: 5.4438 - mean_squared_error: 11.0352 - mean_absolute_error: 2.7847
Epoch 82/100
768/768 [==============================] - 0s 83us/sample - loss: 5.4416 - mean_squared_error: 8.8724 - mean_absolute_error: 2.4634
Epoch 83/100
768/768 [==============================] - 0s 96us/sample - loss: 5.4395 - mean_squared_error: 7.0467 - mean_absolute_error: 2.1836
Epoch 84/100
768/768 [==============================] - 0s 86us/sample - loss: 8.0375 - mean_squared_error: 36.5165 - mean_absolute_error: 4.8413
Epoch 85/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0764 - mean_squared_error: 126.9524 - mean_absolute_error: 10.2454
Epoch 86/100
768/768 [==============================] - 0s 87us/sample - loss: 10.0705 - mean_squared_error: 121.3718 - mean_absolute_error: 9.9911
Epoch 87/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0631 - mean_squared_error: 96.0288 - mean_absolute_error: 8.9118
Epoch 88/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0572 - mean_squared_error: 74.3836 - mean_absolute_error: 7.9054
Epoch 89/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0524 - mean_squared_error: 62.7223 - mean_absolute_error: 7.1927
Epoch 90/100
768/768 [==============================] - 0s 90us/sample - loss: 10.0484 - mean_squared_error: 48.8116 - mean_absolute_error: 6.4094
Epoch 91/100
768/768 [==============================] - 0s 93us/sample - loss: 10.0448 - mean_squared_error: 39.1147 - mean_absolute_error: 5.7639
Epoch 92/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0417 - mean_squared_error: 32.7087 - mean_absolute_error: 5.2643
Epoch 93/100
768/768 [==============================] - 0s 85us/sample - loss: 10.0389 - mean_squared_error: 26.4908 - mean_absolute_error: 4.7354
Epoch 94/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0363 - mean_squared_error: 21.6876 - mean_absolute_error: 4.2937
Epoch 95/100
768/768 [==============================] - 0s 89us/sample - loss: 10.0340 - mean_squared_error: 17.6745 - mean_absolute_error: 3.8886
Epoch 96/100
768/768 [==============================] - 0s 86us/sample - loss: 10.0318 - mean_squared_error: 14.5234 - mean_absolute_error: 3.5385
Epoch 97/100
768/768 [==============================] - 0s 93us/sample - loss: 10.0298 - mean_squared_error: 12.3609 - mean_absolute_error: 3.2538
Epoch 98/100
768/768 [==============================] - 0s 91us/sample - loss: 10.0279 - mean_squared_error: 10.0023 - mean_absolute_error: 2.9435
Epoch 99/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0261 - mean_squared_error: 8.6058 - mean_absolute_error: 2.7176
Epoch 100/100
768/768 [==============================] - 0s 88us/sample - loss: 10.0244 - mean_squared_error: 7.0987 - mean_absolute_error: 2.4628

Hope this answers your question. Happy Learning.


问:
Hiding and showing multiple views using the same animation
I want to apply an animation for multiple views at the same time, how can I apply said animation to several types of views (buttons, imageviews, and other views)?</p>

答: You can create one large AnimatorSet() that includes several ObjectAnimators. This allows you to play all animations at the same time with no delay. See my answer here.</p>

ContentLicense: CC BY-SA 3.0


问:
No module named pandas_datareader
I have just installed pandas_datareader using pip install pandas-datareader which ran successfully.

Now I am trying to use it for a tutorial and I am getting this error when I try to import.

```<code>    import pandas_datareader as pdr

ModuleNotFoundError: No module named 'pandas_datareader'
</code>```

This is the link to the tutorial.

https://www.datacamp.com/community/tutorials/finance-python-trading#gs.DgsO1BY

Any ideas?

答:
If you are facing this issue in Jupyter Notebook, just restart the kernel within the IDE.
-Make sure u have installed pandas_datareader with "pip install pandas_datareader"
-Click on the tab named 'kernel'
-Click Restart

Your Problem will be resolved

Title: No module named pandas_datareader

Body:
I have just installed pandas_datareader using pip install pandas-datareader which ran successfully.

Now I am trying to use it for a tutorial and I am getting this error when I try to import.

    import pandas_datareader as pdr

ModuleNotFoundError: No module named 'pandas_datareader'

This is the link to the tutorial.

https://www.datacamp.com/community/tutorials/finance-python-trading#gs.DgsO1BY

Any ideas?


问:
Flutter - How to set status bar color when AppBar not present
How to set status bar color when AppBar not present.

I have tried this but not working.

```<code>Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    return new Scaffold(
        body: new Container(
        color: UniQueryColors.colorBackground,
        child: new ListView.builder(
           itemCount: 7,
           itemBuilder: (BuildContext context, int index){
             if (index == 0){
               return addTopInfoSection();
             }
           },
        ),
       ),
    );
}
</code>```

Output look like this:

答:
I tried many methods but they didn’t work. And i found another method, use safeArea ,AnnotatedRegion and Scaffold

```<code>AnnotatedRegion(
  // status icon and text color, dark:black  light:white
  value: SystemUiOverlayStyle.dark,
  child: Scaffold(
     // statusbar color
     backgroundColor: Colors.white,
     body : SafeArea(****)
  )
}
</code>```

The code implements the white status bar and black text

Body:
How to set status bar color when AppBar not present.

I have tried this but not working.

Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    return new Scaffold(
        body: new Container(
        color: UniQueryColors.colorBackground,
        child: new ListView.builder(
           itemCount: 7,
           itemBuilder: (BuildContext context, int index){
             if (index == 0){
               return addTopInfoSection();
             }
           },
        ),
       ),
    );
}

Output look like this:

Body:
I tried many methods but they didn’t work. And i found another method, use safeArea ,AnnotatedRegion and Scaffold

AnnotatedRegion(
  // status icon and text color, dark:black  light:white
  value: SystemUiOverlayStyle.dark,
  child: Scaffold(
     // statusbar color
     backgroundColor: Colors.white,
     body : SafeArea(****)
  )
}

The code implements the white status bar and black text


问:
Join two tables and import as one Indice into Algolia?
I'm using Laravel and I'm wondering, is it possible to create a join, and then import that result as an Indice into Algolia for Searching? I know that Algolia imports models, so I'm not sure if there's a way this can be done. I'm using Laravel Scout and Algolia for search and Vue js for my front-end. This would solve the problem that I am having.
Thanks in advance.</p>

答:
You can try to customize the searchable data that is synchronized to Algolia by specifying toSearchableArray() method on the model. In that method, you can pass in the model and relation (whichever model you want to join with) data. More info:
https://laravel.com/docs/7.x/scout#configuring-searchable-data


问:
What is returned if a select statement returns no rows?
I'm working with SQL now in my programming, and I'm querying a database, like so.

```<code>scCommand = new SqlCommand("SELECT LegislationID FROM Legislation WHERE Number =  @ECERegulation", sconConnection);
        scCommand.Parameters.Add("@ECERegulation", SqlDbType.NVarChar);
        scCommand.Parameters["@ECERegulation"].Value = strECERegulation;

        return (int)scCommand.ExecuteScalar();
</code>```

My question is, what would be returned if my parameter did not match anything in the table that I am querying?  I need to have an if statement to deal with a non-matching ECERegulation.  Would it return null?  Or would it return the LegislationID of zero?  Any help would be appreciated.

答:
You can match the null by using Nullable< int >. You can also pass the casting error and return null like this.</p>

```<code>int? GetSomething()
{
     .....
     .....
     return (int?)TypeDescriptor.GetConverter(typeof(int?)).ConvertFrom(scCommand.ExecuteScalar());
}
</code>```

Body:
I'm working with SQL now in my programming, and I'm querying a database, like so.

scCommand = new SqlCommand("SELECT LegislationID FROM Legislation WHERE Number =  @ECERegulation", sconConnection);
        scCommand.Parameters.Add("@ECERegulation", SqlDbType.NVarChar);
        scCommand.Parameters["@ECERegulation"].Value = strECERegulation;

        return (int)scCommand.ExecuteScalar();

My question is, what would be returned if my parameter did not match anything in the table that I am querying?  I need to have an if statement to deal with a non-matching ECERegulation.  Would it return null?  Or would it return the LegislationID of zero?  Any help would be appreciated.

Body:
You can match the null by using Nullable< int >. You can also pass the casting error and return null like this.

int? GetSomething()
{
     .....
     .....
     return (int?)TypeDescriptor.GetConverter(typeof(int?)).ConvertFrom(scCommand.ExecuteScalar());
}


问:
convert a git tag into a branch
I cloned a repository. In the repository there are several branches but there is also a tag.
Now, I have been instructed to work with the version of that tag.

however I have to do some integration and make some more commits from that tag.

I don't know where in the structure of branches this tag is, so what I would like to do is to transform this tag into a branch (right now, after checkout to that tag I am into a "dettached state") so that later I can do commits merges etc.

Is there a way to do this?

答:
You can just checkout the tag:

```<code>git checkout tag_name
</code>```

then create a new branch from it, since tags are read only, and you only push the change to the branch (for bug fix or feature):

```<code>git checkout -b new_branch
</code>```

Title: convert a git tag into a branch

Body:
You can just checkout the tag:

git checkout tag_name

then create a new branch from it, since tags are read only, and you only push the change to the branch (for bug fix or feature):

git checkout -b new_branch


问:
Creating a Bitmap ByteBuffer for quantized Tensorflow Lite Model
I would like to use a quantized tensorflow lite model but the current ByteBuffer I have is using floating point. I would like this to be integer representation. Right now the model wants 270000 bytes and I am trying to pass it 1080000 bytes. Is it as simple as casting the float to int?

```<code>public ByteBuffer convertBitmapToByteBuffer(Bitmap bitmap) {

    // Preallocate memory for bytebuffer
    ByteBuffer byteBuffer = ByteBuffer.allocate(inputSize*inputSize*pixelSize);
    byteBuffer.order(ByteOrder.nativeOrder());

    // Initialize pixel data array and populate from bitmap
    int [] intArray = new int[inputSize*inputSize];
    bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0 , 0,
            bitmap.getWidth(), bitmap.getHeight());

    int pixel = 0;      // pixel indexer
    for (int i=0; i<inputSize; i++) {
        for (int j=0; j<inputSize; j++) {
            int input = intArray[pixel++];

            byteBuffer.putfloat((((input >> 16 & 0x000000FF) - imageMean) / imageStd));
            byteBuffer.putfloat((((input >> 8 & 0x000000FF) - imageMean) / imageStd));
            byteBuffer.putfloat((((input & 0x000000FF) - imageMean) / imageStd));
        }
    }
    return byteBuffer;
}
</code>```

Thanks for any tips you can provide.

答:
Casting float to int is not the correct approach. Good news is that the quantized input values expected by the model (8-bit r, g, b values in sequence) matches exactly the same as the Bitmap pixel representation except that the model doesn't expect an alpha channel, so the conversion process should be actually easier than when you're using float inputs.

Here's what you might try instead. (I'm assuming pixelSize is 3)

int pixel = 0;      // pixel indexer
for (int i=0; i<inputSize; i++) {
    for (int j=0; j<inputSize; j++) {
        int input = intArray[pixel++];   // pixel containing ARGB.
        byteBuffer
            .put((byte)((input >> 16) & 0xFF))    // R
            .put((byte)((input >>  8) & 0xFF))    // G
            .put((byte)((input      ) & 0xFF));   // B
    }
}
```

Body:
I would like to use a quantized tensorflow lite model but the current ByteBuffer I have is using floating point. I would like this to be integer representation. Right now the model wants 270000 bytes and I am trying to pass it 1080000 bytes. Is it as simple as casting the float to int?

public ByteBuffer convertBitmapToByteBuffer(Bitmap bitmap) {

    // Preallocate memory for bytebuffer
    ByteBuffer byteBuffer = ByteBuffer.allocate(inputSize*inputSize*pixelSize);
    byteBuffer.order(ByteOrder.nativeOrder());

    // Initialize pixel data array and populate from bitmap
    int [] intArray = new int[inputSize*inputSize];
    bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0 , 0,
            bitmap.getWidth(), bitmap.getHeight());

    int pixel = 0;      // pixel indexer
    for (int i=0; i<inputSize; i++) {
        for (int j=0; j<inputSize; j++) {
            int input = intArray[pixel++];

            byteBuffer.putfloat((((input >> 16 & 0x000000FF) - imageMean) / imageStd));
            byteBuffer.putfloat((((input >> 8 & 0x000000FF) - imageMean) / imageStd));
            byteBuffer.putfloat((((input & 0x000000FF) - imageMean) / imageStd));
        }
    }
    return byteBuffer;
}

Thanks for any tips you can provide.


问:
Is C# a high level language?
Is C# a high level language? I see it as more like medium level, but I am still unsure about this. Would you consider it as high level as some of the popular scripting languages?

Or does it accommodate more than one level?

答: Yes, it is high-level.  Very.  You are the only one who recognizes 'medium-level language' as a term. :)</p>

OwnerDisplayName: Joan Venge

ContentLicense: CC BY-SA 2.5

Title: Is C# a high level language?

OwnerDisplayName: chaos


问:
What to use for animation for iPad? SVG? GIF? Other?
I am making an app for the iPad/iphone and I want to have a star that tinkles every now and then and/or a rocket that shoots up randomly . What would be the best way to do that? Someone told me to use SVG and another told me that GIFs would be just fine. </p>

答: SVG isn't going to work unless you are displaying the content in a UIWebView, you can either build the views using drawing code and perform the animations with core animation or use images, the first being far more efficient. Check out Apple's Core Animation Guide for more information. </p>

OwnerDisplayName: Zaask


问:
ISO proper way to chain Webpack via vue.config.js to add global .scss imports to my .vue files (vue-cli-plugin-nativescript-vue)
I have Vue.js project I've setup previously that dynamically adds defined .scss files to my .vue template files, so I can access my variables, mixins, etc. in the templates without @importing them, or having them duplicate code from imports.

My problem is I'm setting up a NativeScript/Vue.js project with vue-cli-plugin-nativescript-vue and was curious if anyone has successfully setup their webpack to allow the same functionality. It's my understanding that the plugin replaces webpack with the latest when you run, as specified in the docs https://cli.vuejs.org/guide/webpack.html#replacing-loaders-of-a-rule.

Below is my vue.config.js (which compiles with no error) but doesn't seem to be working. I'm probably missing something or don't understand exactly how this is working, any help is appreciated.

```<code>
const path = require('path')

module.exports = {
    chainWebpack: config => {
        const ofs = ['vue-modules', 'vue', 'normal-modules', 'normal']
        const cssRules = config.module.rule('css')
        const postRules = config.module.rule('postcss')

        const addSassResourcesLoader = (rules, type) => {
            rules
                .oneOf(type)
                .use('sass-resoureces-loader')
                .loader('sass-resources-loader')
                .options({
                    resources: './src/styles/_global.scss', // your resource file or patterns
                })
        }
        ofs.forEach(type => {
            addSassResourcesLoader(cssRules, type)
            addSassResourcesLoader(postRules, type)
        })
        return config
    },
}
</code>```

答:
Vue CLI provides a config to augment your CSS loaders:

// vue.config.js
module.exports = {
  css: {
    loaderOptions: {
      scss: {
        // sass-loader@^8.0.0
        prependData: `import "~@/styles/_global.scss";`,

        // sass-loader@^9.0.0 or newer
        additionalData: `import "~@/styles/_global.scss";`,
      }
    }
  }
}
```

Body:
I have Vue.js project I've setup previously that dynamically adds defined .scss files to my .vue template files, so I can access my variables, mixins, etc. in the templates without @importing them, or having them duplicate code from imports.

My problem is I'm setting up a NativeScript/Vue.js project with vue-cli-plugin-nativescript-vue and was curious if anyone has successfully setup their webpack to allow the same functionality. It's my understanding that the plugin replaces webpack with the latest when you run, as specified in the docs https://cli.vuejs.org/guide/webpack.html#replacing-loaders-of-a-rule.

Below is my vue.config.js (which compiles with no error) but doesn't seem to be working. I'm probably missing something or don't understand exactly how this is working, any help is appreciated.

const path = require('path')

module.exports = {
    chainWebpack: config => {
        const ofs = ['vue-modules', 'vue', 'normal-modules', 'normal']
        const cssRules = config.module.rule('css')
        const postRules = config.module.rule('postcss')

        const addSassResourcesLoader = (rules, type) => {
            rules
                .oneOf(type)
                .use('sass-resoureces-loader')
                .loader('sass-resources-loader')
                .options({
                    resources: './src/styles/_global.scss', // your resource file or patterns
                })
        }
        ofs.forEach(type => {
            addSassResourcesLoader(cssRules, type)
            addSassResourcesLoader(postRules, type)
        })
        return config
    },
}


问:
Oracle birthday column regex constrain violated
I want all my dates in my database in the following yyyy-mm-dd date format. For example, '2020-05-28'. But this doesn't seem to work as I thought it would when I insert a date into my User table which contains the birthday column.

Here's my birthday column constraint :

```<code>birthday DATE NOT NULL CHECK (REGEXP_LIKE(birthday , '\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*')),
</code>```

I get the following error when I try to insert : '2020-05-28' or any other date for that matter :

```<code>02290. 00000 -  "check constraint (%s.%s) violated"
*Cause:    The values being inserted do not satisfy the named check

*Action:   do not insert values that violate the constraint.
</code>```

答:
You are wrongly interpreting the concept of the DATE datatype. Probably, you are mixing the display format of dates (the value that you see when you  display a date  value), and their internal representation.

A date is just that: a date. It is stored internally in some database specific format, that you don't need to worry about. So there is no need for a check constraint to control the format.

Whenever you need to display date, you can use function to_char() to format it as a string, like:

```<code>to_char(birthday, 'yyyy-mm-dd')
</code>```

You can also set session parameter NLS_DATE_FORMAT so all dates are automatically formated in a given format when displayed:

```<code>alter session set nls_date_format = 'yyyy-mm-dd';
</code>```

Body:
I want all my dates in my database in the following yyyy-mm-dd date format. For example, '2020-05-28'. But this doesn't seem to work as I thought it would when I insert a date into my User table which contains the birthday column.

Here's my birthday column constraint :

birthday DATE NOT NULL CHECK (REGEXP_LIKE(birthday , '\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*')),

I get the following error when I try to insert : '2020-05-28' or any other date for that matter :

02290. 00000 -  "check constraint (%s.%s) violated"
*Cause:    The values being inserted do not satisfy the named check

*Action:   do not insert values that violate the constraint.

Body:
You are wrongly interpreting the concept of the DATE datatype. Probably, you are mixing the display format of dates (the value that you see when you  display a date  value), and their internal representation.

A date is just that: a date. It is stored internally in some database specific format, that you don't need to worry about. So there is no need for a check constraint to control the format.

Whenever you need to display date, you can use function to_char() to format it as a string, like:

to_char(birthday, 'yyyy-mm-dd')

You can also set session parameter NLS_DATE_FORMAT so all dates are automatically formated in a given format when displayed:

alter session set nls_date_format = 'yyyy-mm-dd';


问:
Identifying objects in Tosca with Xpath
I am recently brushing up my skills in TOSCA, I was working on it 2 years ago and switched to Selenium, I noticed that the new TOSCA allows identification using Xpath, and I am really familiar with it now, however, I cannot make it work in TOSCA and I am sure the object identification works because I am testing my xpath in google chrome developer tools.

Something as simple as (//*[text()='Forgot Password?'])[1] does not seem to be working.  Could I be missing something?

This is the webpage I am using as reference for this example:
https://www.freecrm.com/index.html

答:
XPath certainly can be used to identify elements of an HTML web UI in Tosca.

Since the question was originally posted, the "Forgot Password?" link at https://www.freecrm.com/index.html appears to have changed so that it's text is now "Forgot your password?" and is actually located at https://ui.freecrm.com/.
To account for that change, this answer uses "(//*[text()='Forgot your password?'])[1]" instead of the expression provided in the original post.

With the text modification, the expression works to idenfity the element in XScan after wrapping it in double quotes:

```<code>"(//*[text()='Forgot your password?'])[1]"
</code>```

Some things to keep in mind when using XPath in Tosca:

It seems that XPath expressions need to be wrapped in double quotes (") so that XScan knows when to start evaluating XPath instead of using its normal rules.  Looking closely at the expression that is pregenerated when XScan starts, we see that it is wrapped in double quotes:

"id('ui')/div[1]/div[1]/div[1]/a[1]"
```

A valid XPath expression doesn't necessarily guarantee uniqueness, so it is helpful to pay attention to any feedback messages at the bottom of XScan.  There is a significant difference between "The selected element was not found" and "The selected element is not unique".  The former simply indicates XScan can't find a match, the latter indicates that XScan matches successfully, but cannot uniquely identify the element.

My experience has been that it helps to explicitly identify the element to reduce the possibility of ambiguity.  If the idea is to target the anchor element in order for tests to click a link, then reducing scope from any element i.e. "(//*[text()='Forgot your Password?'])[1]" to only match anchor elements with that text "//a[text()='Forgot your password?']".

In general, Tricentis (or at least the trainers with whom I have spoken) recommends using methods other than XPath to identify a target if they are available.  That said, in my experience I've had better luck with XPath than with "Identify by Anchor".

An XPath expression is visible and editable in the XModuleAttribute properties without having to rescan.  Personally, I find it easier to work with than the XML value of the RelativeId property that is generated when using Identify by Anchor.

With Anchor, I've had issues where XModuleAttributes scanned in one browser can no longer be found when switching to another browser, specifically from IE to Chrome.  With XPath, I've not had these issues.

While XPath works well to identify the properties of one element with attributes of another because it can identify the relationship between them (very common with controls in Angular applications), the same can often be accomplished by adapting the engine layer using the TBox API (i.e. building a custom control).  This requires some initial work up front from developer resources, but it can significantly improve how tests steer these controls in addition to reducing the need for Automation Specialists to have to rely on XPath.

Title: Identifying objects in Tosca with Xpath

Body:
XPath certainly can be used to identify elements of an HTML web UI in Tosca.

Since the question was originally posted, the "Forgot Password?" link at https://www.freecrm.com/index.html appears to have changed so that it's text is now "Forgot your password?" and is actually located at https://ui.freecrm.com/.
To account for that change, this answer uses "(//*[text()='Forgot your password?'])[1]" instead of the expression provided in the original post.

With the text modification, the expression works to idenfity the element in XScan after wrapping it in double quotes:

"(//*[text()='Forgot your password?'])[1]"

Some things to keep in mind when using XPath in Tosca:

It seems that XPath expressions need to be wrapped in double quotes (") so that XScan knows when to start evaluating XPath instead of using its normal rules.  Looking closely at the expression that is pregenerated when XScan starts, we see that it is wrapped in double quotes:

"id('ui')/div[1]/div[1]/div[1]/a[1]"

A valid XPath expression doesn't necessarily guarantee uniqueness, so it is helpful to pay attention to any feedback messages at the bottom of XScan.  There is a significant difference between "The selected element was not found" and "The selected element is not unique".  The former simply indicates XScan can't find a match, the latter indicates that XScan matches successfully, but cannot uniquely identify the element.

My experience has been that it helps to explicitly identify the element to reduce the possibility of ambiguity.  If the idea is to target the anchor element in order for tests to click a link, then reducing scope from any element i.e. "(//*[text()='Forgot your Password?'])[1]" to only match anchor elements with that text "//a[text()='Forgot your password?']".

In general, Tricentis (or at least the trainers with whom I have spoken) recommends using methods other than XPath to identify a target if they are available.  That said, in my experience I've had better luck with XPath than with "Identify by Anchor".

An XPath expression is visible and editable in the XModuleAttribute properties without having to rescan.  Personally, I find it easier to work with than the XML value of the RelativeId property that is generated when using Identify by Anchor.

With Anchor, I've had issues where XModuleAttributes scanned in one browser can no longer be found when switching to another browser, specifically from IE to Chrome.  With XPath, I've not had these issues.

While XPath works well to identify the properties of one element with attributes of another because it can identify the relationship between them (very common with controls in Angular applications), the same can often be accomplished by adapting the engine layer using the TBox API (i.e. building a custom control).  This requires some initial work up front from developer resources, but it can significantly improve how tests steer these controls in addition to reducing the need for Automation Specialists to have to rely on XPath.


答:
A tag is a name for a commit.  So is a branch name:

$ git rev-parse master
d2ecc46c0981fb829fdfb204604ed0a2798cbe07
$ git rev-parse v2.21.0^{commit}
8104ec994ea3849a968b4667d072fedd1e688642
```

<p>Now, you might wonder what that <code>^{commit}</code> is doing in there.  That's because a tag is often also a name for an <em>annotated tag object</em>, which then names the commit:</p>

<pre class="lang-none prettyprint-override"><code>$ git rev-parse v2.21.0
2bb64867dc05d9a8432488ddc1d22a194cee4d31
$ git cat-file -p 2bb64867dc05d9a8432488ddc1d22a194cee4d31
object 8104ec994ea3849a968b4667d072fedd1e688642
type commit
tag v2.21.0
tagger Junio C Hamano <gitster@pobox.com> 1551023739 -0800

Git 2.21
-----BEGIN PGP SIGNATURE-----
[snip]
</code>```

If you want to start a branch at the commit selected by a tag, just do that:

```<code>git branch newbranch v2.21.0
</code>```

You don't need the ^{commit} as git branch itself figures that out for you:

$ git branch newbranch v2.21.0
$ git rev-parse newbranch
8104ec994ea3849a968b4667d072fedd1e688642
```

<p>What you probably <em>should not</em> do is remove the tag name and create a new branch name identifying the right commit, nor create a branch name that is the same as the tag name.  Both of these are <em>allowed</em> but neither produces happy-making results.</p>

<p>In particular, once a tag has gotten around, <em>every Git repository that has picked it up since then <strong>knows</strong> that it is a tag name and that it means <strong>that</strong> commit.</em>  Now you plan to change that fact?  That's not nice to those other Git repositories.</p>

<p>Meanwhile, if you make a branch and tag name that are spelled the same, Git doesn't always resolve things the way you want.  That is:</p>

<pre class="lang-none prettyprint-override"><code>$ git branch v2.21.0 v2.21.0
$ git rev-parse v2.21.0
warning: refname 'v2.21.0' is ambiguous.
2bb64867dc05d9a8432488ddc1d22a194cee4d31
</code>```

Sometimes, the name v2.21.0 will now mean the branch name.  Sometimes it will mean the tag.  Since branch names, by design, move from one commit (the old tip of the branch) to another (the new tip of the branch) as the branch grows, the two names will, in the future, resolve to two different commits.

Just use a different name.  (And, as ROOT points out, you can create the branch after doing a checkout of the tag, by name; or you can do git checkout -b new-branch tag-name to do it all at once.)

Title: convert a git tag into a branch

Body:
I cloned a repository. In the repository there are several branches but there is also a tag.
Now, I have been instructed to work with the version of that tag.

however I have to do some integration and make some more commits from that tag.

I don't know where in the structure of branches this tag is, so what I would like to do is to transform this tag into a branch (right now, after checkout to that tag I am into a "dettached state") so that later I can do commits merges etc.

Is there a way to do this?

Body:
A tag is a name for a commit.  So is a branch name:

$ git rev-parse master
d2ecc46c0981fb829fdfb204604ed0a2798cbe07
$ git rev-parse v2.21.0^{commit}
8104ec994ea3849a968b4667d072fedd1e688642

Now, you might wonder what that ^{commit} is doing in there.  That's because a tag is often also a name for an annotated tag object, which then names the commit:

$ git rev-parse v2.21.0
2bb64867dc05d9a8432488ddc1d22a194cee4d31
$ git cat-file -p 2bb64867dc05d9a8432488ddc1d22a194cee4d31
object 8104ec994ea3849a968b4667d072fedd1e688642
type commit
tag v2.21.0
tagger Junio C Hamano <gitster@pobox.com> 1551023739 -0800

Git 2.21
-----BEGIN PGP SIGNATURE-----
[snip]

If you want to start a branch at the commit selected by a tag, just do that:

git branch newbranch v2.21.0

You don't need the ^{commit} as git branch itself figures that out for you:

$ git branch newbranch v2.21.0
$ git rev-parse newbranch
8104ec994ea3849a968b4667d072fedd1e688642

What you probably should not do is remove the tag name and create a new branch name identifying the right commit, nor create a branch name that is the same as the tag name.  Both of these are allowed but neither produces happy-making results.

In particular, once a tag has gotten around, every Git repository that has picked it up since then knows that it is a tag name and that it means that commit.  Now you plan to change that fact?  That's not nice to those other Git repositories.

Meanwhile, if you make a branch and tag name that are spelled the same, Git doesn't always resolve things the way you want.  That is:

$ git branch v2.21.0 v2.21.0
$ git rev-parse v2.21.0
warning: refname 'v2.21.0' is ambiguous.
2bb64867dc05d9a8432488ddc1d22a194cee4d31

Sometimes, the name v2.21.0 will now mean the branch name.  Sometimes it will mean the tag.  Since branch names, by design, move from one commit (the old tip of the branch) to another (the new tip of the branch) as the branch grows, the two names will, in the future, resolve to two different commits.

Just use a different name.  (And, as ROOT points out, you can create the branch after doing a checkout of the tag, by name; or you can do git checkout -b new-branch tag-name to do it all at once.)


问:
IONIC 5 empty FormData
I am performing a user profile, however when creating the FormData for sending it is being generated empty, even with all other fields having values. Below is the code cadastro.ts

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';

import { AlertController, ActionSheetController } from '@ionic/angular';
import { PictureSourceType, Camera, CameraOptions } from '@ionic-native/camera/ngx';

import { CadastroService } from 'src/app/services/cadastro.service';

@Component({
  selector: 'app-cadastro',
  templateUrl: './cadastro.page.html',
  styleUrls: ['./cadastro.page.scss'],
})
export class CadastroPage implements OnInit {
  public registerForm: FormGroup

  constructor(
    private cadastroService: CadastroService,
    private router: Router,
    private formBuilder: FormBuilder,
    private alertController: AlertController,
    private ActionSheetController: ActionSheetController,
    private camera: Camera,
  ) { }

  ngOnInit() {

    this.registerForm = this.formBuilder.group({
      foto: [''],
      nome: ['', Validators.required],
      email: ['', [Validators.required, Validators.email]],
      cpf: ['', Validators.required],
      telefone: ['', Validators.required],
      password: ['', Validators.required],
      conf_pass: ['', Validators.required]
    })

  }

  cadastrar() {

    console.log(this.registerForm.get('nome').value)

    const formData = new FormData();
    formData.append('nome', this.registerForm.get('nome').value);
    formData.append('email', this.registerForm.get('email').value);
    formData.append('cpf', this.registerForm.get('cpf').value);
    formData.append('telefone', this.registerForm.get('telefone').value);
    formData.append('password', this.registerForm.get('password').value);
    formData.append('file', 'testeFile');

    console.log(formData);

    this.cadastroService.cadastrar(formData).subscribe((res: any) => {
      console.log(res);
    }, error => {
      console.log(error)
    })

  }

}

```

<p>The return from the console log is a FormData {}. However, if I give a console log in any registerForm field, the value will be returned correctly. Does anyone know what may be happening in the construction of this request?</p>

<p>My backend Laravel is the logFile of request:</p>

<pre class="lang-php prettyprint-override"><code>[2020-05-29 03:17:25] local.ALERT: array (
  'data' =>
  array (
  ),
)

</code>```

答:
Form data is alive. But you can't see its data when using console.log(formData) function.
Instead you can see that data like this.</p>

```<code>console.log(formData.get('nome'));
console.log(formData.get('email'));
</code>```

Title: IONIC 5 empty FormData

Body:
I am performing a user profile, however when creating the FormData for sending it is being generated empty, even with all other fields having values. Below is the code cadastro.ts

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';

import { AlertController, ActionSheetController } from '@ionic/angular';
import { PictureSourceType, Camera, CameraOptions } from '@ionic-native/camera/ngx';

import { CadastroService } from 'src/app/services/cadastro.service';

@Component({
  selector: 'app-cadastro',
  templateUrl: './cadastro.page.html',
  styleUrls: ['./cadastro.page.scss'],
})
export class CadastroPage implements OnInit {
  public registerForm: FormGroup

  constructor(
    private cadastroService: CadastroService,
    private router: Router,
    private formBuilder: FormBuilder,
    private alertController: AlertController,
    private ActionSheetController: ActionSheetController,
    private camera: Camera,
  ) { }

  ngOnInit() {

    this.registerForm = this.formBuilder.group({
      foto: [''],
      nome: ['', Validators.required],
      email: ['', [Validators.required, Validators.email]],
      cpf: ['', Validators.required],
      telefone: ['', Validators.required],
      password: ['', Validators.required],
      conf_pass: ['', Validators.required]
    })

  }

  cadastrar() {

    console.log(this.registerForm.get('nome').value)

    const formData = new FormData();
    formData.append('nome', this.registerForm.get('nome').value);
    formData.append('email', this.registerForm.get('email').value);
    formData.append('cpf', this.registerForm.get('cpf').value);
    formData.append('telefone', this.registerForm.get('telefone').value);
    formData.append('password', this.registerForm.get('password').value);
    formData.append('file', 'testeFile');

    console.log(formData);

    this.cadastroService.cadastrar(formData).subscribe((res: any) => {
      console.log(res);
    }, error => {
      console.log(error)
    })

  }

}

The return from the console log is a FormData {}. However, if I give a console log in any registerForm field, the value will be returned correctly. Does anyone know what may be happening in the construction of this request?

My backend Laravel is the logFile of request:

[2020-05-29 03:17:25] local.ALERT: array (
  'data' =>
  array (
  ),
)

Body:
Form data is alive. But you can't see its data when using console.log(formData) function.
Instead you can see that data like this.

console.log(formData.get('nome'));
console.log(formData.get('email'));


问:
How do I get the value from HashMap in my ListView?
I've created my own custom adapter by extending BaseAdapter. I just want to be able to grab the string of the value in my onItemClick method (so I can put it as an intent extra). How can I do that?

My custom adapter looks like this:

```<code>   private class HashMapAdapter extends BaseAdapter {

        private HashMap<String, String> mMap = new HashMap<String, String>();
        private String[] mKeys;
        private Context mContext;

        private HashMapAdapter(Context context, HashMap<String, String> map) {
            mContext = context;
            mMap = map;
            mKeys = mMap.keySet().toArray(new String[map.size()]);
        }

        @Override
        public int getCount() {
            return mMap.size();
        }

        @Override
        public Object getItem(int position) {

            return mMap.get(mKeys[position]);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
//          String key = mKeys[position];

            RowView row;
            if(convertView == null) {
                row = new RowView(getBaseContext());
            } else {
                row = (RowView) convertView;
            }
            row.display(mKeys[position]);
            return row;

        }

    }
</code>```

答:
Not sure why I couldn't get it to work before, but this is how to do it:</p>

```<code>intent.putExtra("url",  arg0.getAdapter().getItem(arg2).toString());
</code>```

Body:
I've created my own custom adapter by extending BaseAdapter. I just want to be able to grab the string of the value in my onItemClick method (so I can put it as an intent extra). How can I do that?

My custom adapter looks like this:

   private class HashMapAdapter extends BaseAdapter {

        private HashMap<String, String> mMap = new HashMap<String, String>();
        private String[] mKeys;
        private Context mContext;

        private HashMapAdapter(Context context, HashMap<String, String> map) {
            mContext = context;
            mMap = map;
            mKeys = mMap.keySet().toArray(new String[map.size()]);
        }

        @Override
        public int getCount() {
            return mMap.size();
        }

        @Override
        public Object getItem(int position) {

            return mMap.get(mKeys[position]);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
//          String key = mKeys[position];

            RowView row;
            if(convertView == null) {
                row = new RowView(getBaseContext());
            } else {
                row = (RowView) convertView;
            }
            row.display(mKeys[position]);
            return row;

        }

    }

Body:
Not sure why I couldn't get it to work before, but this is how to do it:

intent.putExtra("url",  arg0.getAdapter().getItem(arg2).toString());


问:
HIDE Column in Select query?
Hi I'm trying to hide the TotalRank Column that gets displayed during my results because I only needed it in this query to help sort items. I don't need this information displayed.</p>

```<code>SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp, RANK() OVER (ORDER BY TotalRank ASC ) as TotalRank
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID
</code>```

答:
You can use th following </p>

```<code>SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID
ORDER BY  RANK() OVER (ORDER BY TotalRank ASC )
</code>```

Title: HIDE Column in Select query?

Body:
Hi I'm trying to hide the TotalRank Column that gets displayed during my results because I only needed it in this query to help sort items. I don't need this information displayed.

SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp, RANK() OVER (ORDER BY TotalRank ASC ) as TotalRank
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID

Body:
You can use th following

SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID
ORDER BY  RANK() OVER (ORDER BY TotalRank ASC )