Yaohong

为了真相不惜被羞辱

Distribution failed with errors When developing ios App

Distribution failed with errors When developing ios App

Distribution failed with errors:

Asset validation failed

The product archive is invalid. The Info.plist must contain a LSApplicationCategoryType key, whose value is the UTI for a valid category. For more details, see "Submitting your Mac apps to the App Store". (ID: 67f59c1b-bb08-4694-978f-11d07ff31357)

Solve this issue by add following codes on <project root folder>/macos/Runner/Info.plist:

    <key>LSApplicationCategoryType</key>
    <string>public.app-category.productivity</string>

the value of LSApplicationCategoryType refer https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype


Flutter HTTP host maven.google.com is not reachable in Windows

Flutter HTTP host https://maven.google.com/ is not reachable in Windows 10

It shows the following error messages after executing flutter doctor in terminal prompt in Windows 10.

Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1586], locale zh-CN)
[] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[] Chrome - develop for the web
[] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.2)
[] Android Studio (version 4.1)
[] Connected device (4 available)
[!] HTTP Host Availability
    X HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host:
      信号灯超时时间已到

    X HTTP host https://cloud.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host:
      信号灯超时时间已到

How to handle HTTP host https://maven.google.com/ is not reachable?

1.Get the port of your http proxy

For example, my https proxy port is 10809, I get it in Option Settings in the v2 proxy. V2 socks port is 10808, https port is sock port +1 which is 10809;


How backward and step are associated with model paramters update?

How are backward and step associated with model paramters update?

optimizer accept the paramters of the model, it can update the parameters, but how is loss function associated with paramters?

loss.backward()

optimizer.step()

REFERENCE:

1.pytorch - connection between loss.backward() and optimizer.step()

2.https://pytorch.org/tutorials/beginner/former_torchies/nnft_tutorial.html#forward-and-backward-function-hooks


nn_Module

nn_Module

1.Where are module parameters configured?

The parameters are stored in the network node which is one of points of a network layer. Neural network layer is defined in init method of module and need to be defined as class variable;

import torch.nn as nn
import numpy as np
class TorchDNN(nn.Module):

    def __init__(self, input, hidden, output):
        super(TorchDNN, self).__init__();
        layer_hidden = nn.Linear(input, hidden, bias = True);
    def forward(self, input_data):
        pass

x = np.array([1, 2, 3])
torch_model = TorchDNN(len(x), 5, 3)
print(torch_model.state_dict())
# OUTPUT:
# OrderedDict()

Network layer should be defined as a variable of Module class;


Github ssh key didn't work

Check the git URL configuration of your project

Github ssh key didn’t work

After you config a ssh key on github, you can test your ssh connection.

  • 1.Open Terminal.
  • 2.Enter the following:
$ ssh -T git@github.com

If you see your username of github in the resulting message, that means you configure successfully.

But, when you run git pull under the root of the project, the it prompt you to enter your Username of github, what is wrong?!

Now you should check that the URL in git config file starts with git@, instead of the http or https:


Understanding arange, unsqueeze, repeat, stack methods in Pytorch

Understanding arange, unsqueeze, repeat, stack methods in Pytorch

  • torch.arange(start=0, end, step=1) return 1-D tensor of size (end-start)/step which value begin from start and each value take with common differences step.

  • torch.unsqueeze(input, dim) return a new tensor with a dimension of size one insterted at specified position; A dim value within the range [-input.dim() - 1, input.dim() + 1) can be used.

  • tensor.repeat(size*) return a tensor; the new shape of tensor is that original shape multiplied by arguments correspondingly, if the number of paramter don’t match the original shape, then last dimension of new shape = the last dimension of original shape * last paramter;


L1 L2 Regularization - Optimizer

Optimizer: L1 L2 Regularization

L1,L2 Loss function mean different type of loss function.

L1: sum(Y-f(x))     lasso
L2: sum(Y-f(x))^2   Ridge

L1, L2 regularization :

Y_predict = E(w_i(x_i)+b_i)

MES = E(Y-Y_predict)^2

L1: loss = MSE + 入E|w_i|
L2: loss = MES + 入E(w_i)^2

What does penalize the weights?

It means add another parameters to the loss function, so that the greater the weight, the higher the loss function value. That makes the weight parameters to be less or smaller.


How to Label Voice with Praat for Machine Learning

Praat

How to Label Voice with Praat for Machine Learning

1.Install

1.1 Download praat

1.Open Praat: doing Phonetics by Computer website;

2.Choose your OS system on download area in the upper left conner of website;

3.Then click the praat6150_mac.dmg or praat6150_win64.zip to download file;

For example, my os is MacOS, in my case I should download praat6150_mac.dmg and install it.

  • Option: You can also download the file from github, referce to Praat in github

1.2 Install Phonetic symbols

If you want to see good-quality phonetic characters on your screen and in your clipboard, you have to install the Charis SIL and/or the Doulos SIL font.


Github API Basic Authentication Example

Github API Basic Authentication Example

1.Generate Personal access tokens

Open this page Generate Personal access tokens and click Generate new token to get a token;

2.Use access token to request Github REST api

2.1 Install requests with pip;

pip install requests

2.2 Sustitute GITHUB_API_USER_NAME with your user name and GITHUB_API_PERSONAL_TOKEN with the token you got in step one, then run the following code;

from requests import Request, Session
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects

def getRateLimit():
    url = 'https://api.github.com/rate_limit'
    print(url)
    parameters = {
    }
    headers = {
        'Accept':'application/vnd.github.v3+json',
    }
    session = Session()
    session.auth = ("GITHUB_API_USER_NAME", "GITHUB_API_PERSONAL_TOKEN")
    session.headers.update(headers)
    data = None;
    try:
        response = session.get(url, params=parameters)
        return response;
    except (ConnectionError, Timeout, TooManyRedirects) as e:
        print(e)
    return data;

if __name__ == '__main__':
    rs = getRateLimit()
    # print(rs.headers)
    print(rs.text)


## Output:
## if your access token is correct, the limit of core of resources should be 5000 rather than 60.
{"resources":{"core":{"limit":5000,"used":1245,"remaining":3755,"reset":1625664206},"search":{"limit":30,"used":0,"remaining":30,"reset":1625662728},"graphql":{"limit":5000,"used":0,"remaining":5000,"reset":1625666268},"integration_manifest":{"limit":5000,"used":0,"remaining":5000,"reset":1625666268},"source_import":{"limit":100,"used":0,"remaining":100,"reset":1625662728},"code_scanning_upload":{"limit":500,"used":0,"remaining":500,"reset":1625666268}},"rate":{"limit":5000,"used":1245,"remaining":3755,"reset":1625664206}}

REFERENCE: 1.Other authentication methods


Anacode simple usage

Anacode simple usage

1.1 Download and install –Mac os

Download file: click to download

Install after download.

Run command in terminal to see your anconda version:

$conda -V
conda 4.10.1

Use conda info to see conda configuration:

(base) $ conda info 

2.Anaconda Usage

2.1 List all enviroments

(base) $ conda info -e
# conda environments:
#
base                     /Users/Rhys/opt/anaconda3

2.1 create an enviroment

(base) $ conda create -n py36 python=3.6

2.2 activate an enviroment

(base) $ conda activate py36
(py36) $ 

The environment had changed after activating;