Mia  Marquardt

Mia Marquardt

1622769608

How to Split a Tensorflow Dataset into Train, Validation, and Test sets

Why and when training, validation, and testing splits are needed and how to build them from a tf.data.Dataset using Python

Why and when do we need train, validation, and test splits?

One of the biggest challenges when developing a machine learning model is to prevent it from overfitting to the data set. The difficulty arises when the model learns a combination of weights that performs well on the data used for training but fails to generalize when the model is given images it has never seen. This is known as overfitting.

When implementing a model that will be deployed in the real world, we might want to have an estimate of how it will behave once it is put into production. This is where the test set comes into play, a random partition of the original dataset that is intended to represent data not used for training, so that we can have an estimate of how our model will behave with unseen data.

In addition, there is a third set that is useful when we plan to experiment with different configurations of our model, such as alternative architectures, optimizers, or loss functions, also known as hyperparameter-tuning. To compare the performance of these experiments, another random split can be extracted from the original data set, which is not used for training nor testing but to validate our model in different configurations. This is known as the validation set.

Now, you might be wondering, but then, validation and test sets have the same purpose, right? Well, it is true that both datasets serve to have an estimation of how our model performs on data that have not been used for training. However, when trying different model configurations to have the best validation metrics, we are in a way fitting our model to the validation set, choosing the combination of parameters with the best performance on that set.

Once we have run our hyperparameter-tuning and have the model that performs best, the test set allows us to get an idea of how well this model will perform in production. Therefore, it should only be used at the end of the project.

#metrics #training #machine-learning #data-science #tensorflow

What is GEEK

Buddha Community

How to Split a Tensorflow Dataset into Train, Validation, and Test sets
Hermann  Frami

Hermann Frami

1651383480

A Simple Wrapper Around Amplify AppSync Simulator

This serverless plugin is a wrapper for amplify-appsync-simulator made for testing AppSync APIs built with serverless-appsync-plugin.

Install

npm install serverless-appsync-simulator
# or
yarn add serverless-appsync-simulator

Usage

This plugin relies on your serverless yml file and on the serverless-offline plugin.

plugins:
  - serverless-dynamodb-local # only if you need dynamodb resolvers and you don't have an external dynamodb
  - serverless-appsync-simulator
  - serverless-offline

Note: Order is important serverless-appsync-simulator must go before serverless-offline

To start the simulator, run the following command:

sls offline start

You should see in the logs something like:

...
Serverless: AppSync endpoint: http://localhost:20002/graphql
Serverless: GraphiQl: http://localhost:20002
...

Configuration

Put options under custom.appsync-simulator in your serverless.yml file

| option | default | description | | ------------------------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | | apiKey | 0123456789 | When using API_KEY as authentication type, the key to authenticate to the endpoint. | | port | 20002 | AppSync operations port; if using multiple APIs, the value of this option will be used as a starting point, and each other API will have a port of lastPort + 10 (e.g. 20002, 20012, 20022, etc.) | | wsPort | 20003 | AppSync subscriptions port; if using multiple APIs, the value of this option will be used as a starting point, and each other API will have a port of lastPort + 10 (e.g. 20003, 20013, 20023, etc.) | | location | . (base directory) | Location of the lambda functions handlers. | | refMap | {} | A mapping of resource resolutions for the Ref function | | getAttMap | {} | A mapping of resource resolutions for the GetAtt function | | importValueMap | {} | A mapping of resource resolutions for the ImportValue function | | functions | {} | A mapping of external functions for providing invoke url for external fucntions | | dynamoDb.endpoint | http://localhost:8000 | Dynamodb endpoint. Specify it if you're not using serverless-dynamodb-local. Otherwise, port is taken from dynamodb-local conf | | dynamoDb.region | localhost | Dynamodb region. Specify it if you're connecting to a remote Dynamodb intance. | | dynamoDb.accessKeyId | DEFAULT_ACCESS_KEY | AWS Access Key ID to access DynamoDB | | dynamoDb.secretAccessKey | DEFAULT_SECRET | AWS Secret Key to access DynamoDB | | dynamoDb.sessionToken | DEFAULT_ACCESS_TOKEEN | AWS Session Token to access DynamoDB, only if you have temporary security credentials configured on AWS | | dynamoDb.* | | You can add every configuration accepted by DynamoDB SDK | | rds.dbName | | Name of the database | | rds.dbHost | | Database host | | rds.dbDialect | | Database dialect. Possible values (mysql | postgres) | | rds.dbUsername | | Database username | | rds.dbPassword | | Database password | | rds.dbPort | | Database port | | watch | - *.graphql
- *.vtl | Array of glob patterns to watch for hot-reloading. |

Example:

custom:
  appsync-simulator:
    location: '.webpack/service' # use webpack build directory
    dynamoDb:
      endpoint: 'http://my-custom-dynamo:8000'

Hot-reloading

By default, the simulator will hot-relad when changes to *.graphql or *.vtl files are detected. Changes to *.yml files are not supported (yet? - this is a Serverless Framework limitation). You will need to restart the simulator each time you change yml files.

Hot-reloading relies on watchman. Make sure it is installed on your system.

You can change the files being watched with the watch option, which is then passed to watchman as the match expression.

e.g.

custom:
  appsync-simulator:
    watch:
      - ["match", "handlers/**/*.vtl", "wholename"] # => array is interpreted as the literal match expression
      - "*.graphql"                                 # => string like this is equivalent to `["match", "*.graphql"]`

Or you can opt-out by leaving an empty array or set the option to false

Note: Functions should not require hot-reloading, unless you are using a transpiler or a bundler (such as webpack, babel or typescript), un which case you should delegate hot-reloading to that instead.

Resource CloudFormation functions resolution

This plugin supports some resources resolution from the Ref, Fn::GetAtt and Fn::ImportValue functions in your yaml file. It also supports some other Cfn functions such as Fn::Join, Fb::Sub, etc.

Note: Under the hood, this features relies on the cfn-resolver-lib package. For more info on supported cfn functions, refer to the documentation

Basic usage

You can reference resources in your functions' environment variables (that will be accessible from your lambda functions) or datasource definitions. The plugin will automatically resolve them for you.

provider:
  environment:
    BUCKET_NAME:
      Ref: MyBucket # resolves to `my-bucket-name`

resources:
  Resources:
    MyDbTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: myTable
      ...
    MyBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-bucket-name
    ...

# in your appsync config
dataSources:
  - type: AMAZON_DYNAMODB
    name: dynamosource
    config:
      tableName:
        Ref: MyDbTable # resolves to `myTable`

Override (or mock) values

Sometimes, some references cannot be resolved, as they come from an Output from Cloudformation; or you might want to use mocked values in your local environment.

In those cases, you can define (or override) those values using the refMap, getAttMap and importValueMap options.

  • refMap takes a mapping of resource name to value pairs
  • getAttMap takes a mapping of resource name to attribute/values pairs
  • importValueMap takes a mapping of import name to values pairs

Example:

custom:
  appsync-simulator:
    refMap:
      # Override `MyDbTable` resolution from the previous example.
      MyDbTable: 'mock-myTable'
    getAttMap:
      # define ElasticSearchInstance DomainName
      ElasticSearchInstance:
        DomainEndpoint: 'localhost:9200'
    importValueMap:
      other-service-api-url: 'https://other.api.url.com/graphql'

# in your appsync config
dataSources:
  - type: AMAZON_ELASTICSEARCH
    name: elasticsource
    config:
      # endpoint resolves as 'http://localhost:9200'
      endpoint:
        Fn::Join:
          - ''
          - - https://
            - Fn::GetAtt:
                - ElasticSearchInstance
                - DomainEndpoint

Key-value mock notation

In some special cases you will need to use key-value mock nottation. Good example can be case when you need to include serverless stage value (${self:provider.stage}) in the import name.

This notation can be used with all mocks - refMap, getAttMap and importValueMap

provider:
  environment:
    FINISH_ACTIVITY_FUNCTION_ARN:
      Fn::ImportValue: other-service-api-${self:provider.stage}-url

custom:
  serverless-appsync-simulator:
    importValueMap:
      - key: other-service-api-${self:provider.stage}-url
        value: 'https://other.api.url.com/graphql'

Limitations

This plugin only tries to resolve the following parts of the yml tree:

  • provider.environment
  • functions[*].environment
  • custom.appSync

If you have the need of resolving others, feel free to open an issue and explain your use case.

For now, the supported resources to be automatically resovled by Ref: are:

  • DynamoDb tables
  • S3 Buckets

Feel free to open a PR or an issue to extend them as well.

External functions

When a function is not defined withing the current serverless file you can still call it by providing an invoke url which should point to a REST method. Make sure you specify "get" or "post" for the method. Default is "get", but you probably want "post".

custom:
  appsync-simulator:
    functions:
      addUser:
        url: http://localhost:3016/2015-03-31/functions/addUser/invocations
        method: post
      addPost:
        url: https://jsonplaceholder.typicode.com/posts
        method: post

Supported Resolver types

This plugin supports resolvers implemented by amplify-appsync-simulator, as well as custom resolvers.

From Aws Amplify:

  • NONE
  • AWS_LAMBDA
  • AMAZON_DYNAMODB
  • PIPELINE

Implemented by this plugin

  • AMAZON_ELASTIC_SEARCH
  • HTTP
  • RELATIONAL_DATABASE

Relational Database

Sample VTL for a create mutation

#set( $cols = [] )
#set( $vals = [] )
#foreach( $entry in $ctx.args.input.keySet() )
  #set( $regex = "([a-z])([A-Z]+)")
  #set( $replacement = "$1_$2")
  #set( $toSnake = $entry.replaceAll($regex, $replacement).toLowerCase() )
  #set( $discard = $cols.add("$toSnake") )
  #if( $util.isBoolean($ctx.args.input[$entry]) )
      #if( $ctx.args.input[$entry] )
        #set( $discard = $vals.add("1") )
      #else
        #set( $discard = $vals.add("0") )
      #end
  #else
      #set( $discard = $vals.add("'$ctx.args.input[$entry]'") )
  #end
#end
#set( $valStr = $vals.toString().replace("[","(").replace("]",")") )
#set( $colStr = $cols.toString().replace("[","(").replace("]",")") )
#if ( $valStr.substring(0, 1) != '(' )
  #set( $valStr = "($valStr)" )
#end
#if ( $colStr.substring(0, 1) != '(' )
  #set( $colStr = "($colStr)" )
#end
{
  "version": "2018-05-29",
  "statements":   ["INSERT INTO <name-of-table> $colStr VALUES $valStr", "SELECT * FROM    <name-of-table> ORDER BY id DESC LIMIT 1"]
}

Sample VTL for an update mutation

#set( $update = "" )
#set( $equals = "=" )
#foreach( $entry in $ctx.args.input.keySet() )
  #set( $cur = $ctx.args.input[$entry] )
  #set( $regex = "([a-z])([A-Z]+)")
  #set( $replacement = "$1_$2")
  #set( $toSnake = $entry.replaceAll($regex, $replacement).toLowerCase() )
  #if( $util.isBoolean($cur) )
      #if( $cur )
        #set ( $cur = "1" )
      #else
        #set ( $cur = "0" )
      #end
  #end
  #if ( $util.isNullOrEmpty($update) )
      #set($update = "$toSnake$equals'$cur'" )
  #else
      #set($update = "$update,$toSnake$equals'$cur'" )
  #end
#end
{
  "version": "2018-05-29",
  "statements":   ["UPDATE <name-of-table> SET $update WHERE id=$ctx.args.input.id", "SELECT * FROM <name-of-table> WHERE id=$ctx.args.input.id"]
}

Sample resolver for delete mutation

{
  "version": "2018-05-29",
  "statements":   ["UPDATE <name-of-table> set deleted_at=NOW() WHERE id=$ctx.args.id", "SELECT * FROM <name-of-table> WHERE id=$ctx.args.id"]
}

Sample mutation response VTL with support for handling AWSDateTime

#set ( $index = -1)
#set ( $result = $util.parseJson($ctx.result) )
#set ( $meta = $result.sqlStatementResults[1].columnMetadata)
#foreach ($column in $meta)
    #set ($index = $index + 1)
    #if ( $column["typeName"] == "timestamptz" )
        #set ($time = $result["sqlStatementResults"][1]["records"][0][$index]["stringValue"] )
        #set ( $nowEpochMillis = $util.time.parseFormattedToEpochMilliSeconds("$time.substring(0,19)+0000", "yyyy-MM-dd HH:mm:ssZ") )
        #set ( $isoDateTime = $util.time.epochMilliSecondsToISO8601($nowEpochMillis) )
        $util.qr( $result["sqlStatementResults"][1]["records"][0][$index].put("stringValue", "$isoDateTime") )
    #end
#end
#set ( $res = $util.parseJson($util.rds.toJsonString($util.toJson($result)))[1][0] )
#set ( $response = {} )
#foreach($mapKey in $res.keySet())
    #set ( $s = $mapKey.split("_") )
    #set ( $camelCase="" )
    #set ( $isFirst=true )
    #foreach($entry in $s)
        #if ( $isFirst )
          #set ( $first = $entry.substring(0,1) )
        #else
          #set ( $first = $entry.substring(0,1).toUpperCase() )
        #end
        #set ( $isFirst=false )
        #set ( $stringLength = $entry.length() )
        #set ( $remaining = $entry.substring(1, $stringLength) )
        #set ( $camelCase = "$camelCase$first$remaining" )
    #end
    $util.qr( $response.put("$camelCase", $res[$mapKey]) )
#end
$utils.toJson($response)

Using Variable Map

Variable map support is limited and does not differentiate numbers and strings data types, please inject them directly if needed.

Will be escaped properly: null, true, and false values.

{
  "version": "2018-05-29",
  "statements":   [
    "UPDATE <name-of-table> set deleted_at=NOW() WHERE id=:ID",
    "SELECT * FROM <name-of-table> WHERE id=:ID and unix_timestamp > $ctx.args.newerThan"
  ],
  variableMap: {
    ":ID": $ctx.args.id,
##    ":TIMESTAMP": $ctx.args.newerThan -- This will be handled as a string!!!
  }
}

Requires

Author: Serverless-appsync
Source Code: https://github.com/serverless-appsync/serverless-appsync-simulator 
License: MIT License

#serverless #sync #graphql 

A Demo Code Of Training and Testing using Tensorflow

ProbFace, arxiv

This is a demo code of training and testing [ProbFace] using Tensorflow. ProbFace is a reliable Probabilistic Face Embeddging (PFE) method. The representation of each face will be an Guassian distribution parametrized by (mu, sigma), where mu is the original embedding and sigma is the learned uncertainty. Experiments show that ProbFace could

  • improve the robustness of PFE.
  • simplify the calculation of the multal likelihood score (MLS).
  • improve the recognition performance on the risk-controlled scenarios.

#machine learning #tensorflow #testing #a demo code of training and testing using tensorflow #a demo code of training #testing using tensorflow

Ananya Gupta

Ananya Gupta

1609749973

Is Software Testing a Good for Career?

Software Testing is the hottest job at present time. The requirement for a software tester is increasing day by day with a good salary package depended on their skills in the software development companies.

Software testing has become a core part of application/product implementations. The good who want to make a career in software testing because it has a great scope of software testing is increasing day-by-day in the IT field.

The roles of a software tester are given according to their skills and experience. Here are the following is given below:

QA Analyst (Fresher)
Sr. QA Analyst (2-3 years’ experience)
QA Team Coordinator (5-6 years’ experience)
Test Manager (8-11 years’ experience)
Senior Test Manager (14+ experience)

Reasons Why Software Testing Is Good Career Option

Good Salary Package
Software tester gets paid a high salary package on which a software developer gets. It doesn’t matter beginner or fresher payment scale is on the same level all depended on their skill. Companies raise their salary based on skill, experience, and certification.

High In Demand
Now in the modern age competition is high for a software tester to provide high-quality products and services. For quality, final product testing is a basic core screening element which is the demand for Automation software testing is high in comparison to manual testing. Similarly, both software development and testing have great career opportunities for never-ending opportunities.

Easy To Enter In IT Sector
Whatever stream graduates can easily get into the IT sector by completed their online Software testing course. You don’t need to know advanced coding knowledge if you think that requires it. The only matter is interest to learn and work.

Easy To Learn
Many institutes provide software testing courses or online Software training from where you learn tools used for testing can easily by anyone who has an interest. Those who have basic coding skills can enter into software testing. However, It will not be easy for those who choose software testing just because of the trend and don’t have their interest in it.

Work As Freelancer
Software Testing is a flexible job, you can work on freelancing. Now there is the option to work from home in the IT sector in a flexible to maintain a work-life balance.

In other words, many companies prefer freelance work to reduce the cost and also the result is high, therefore one who has done a software testing training course either can work freelance or regular job the decision is up to you.

#software testing online training #software testing online course #software testing training in noida #software testing training in delhi #software testing training #software testing course

vidhu dev

1604573300

Approaches to Mobile Application Testing

Mobile application testing is the process of every application generated for handheld devices has to go through. This is to assure a specific level of the place before a request is delivered into the marketplace (app store/ play store). Mobile Application Testing is one of the software testing of applications on mobile devices to verify that the properties are running easily in terms of their operations, usability, functions, operations, and interaction. Looking for Mobile Testing Training in Chennai? Step into FITA, We are the best leading institution for Mobile Testing Course in Chennai.

There are two different approaches for Mobile Application testing based on their performance, they are:
• Manual testing
• Automated testing

Manual Testing

Manual testing, as the title implies, is a human method, majorly concentrated on user activity. Evaluation and Report of the application’s security, functionality usability arranged through the factor of a user in an explorative method.
This assures that your statement lives up to a model of user-friendliness. This is a type of measurement that is frequently time-consuming as enthusiasts manage to get the opportunity to become identified.
Twenty percent of app testing must be arranged manually through the guidance of beta and alpha releases and remaining must be motorized.
let’s move on to automated mobile application testing.

Automated Testing

Automated testing is secondary access to mobile application testing. In this method, an array of samples tests are structured. It should generally cover 80% of the testing process. The percentage is not required, but a common guideline developed in the software industry. Here is a list of test events that are frequently achieved through this critical method –

• Automate various tedious standard test cases.
• Automate test cases that can be quickly programmed
• Automate test cases that are impossible to perform manually
• Automate test cases for regularly used functionality
• Automate test cases with expected results

Are you looking for Mobile Testing Training in Bangalore? Step into FITA, and build a strong career. FITA one of the best leading institutions for the Mobile Testing Course in Bangalore.

Check out mobile application testing online training at home with instructor-led live practice and real-life project experience.

#mobile testing training in chennai #mobile testing course in chennai #mobile testing training in bangalore #mobile testing course in bangalore #mobile application testing online training #mobile testing online training

Mia  Marquardt

Mia Marquardt

1622769608

How to Split a Tensorflow Dataset into Train, Validation, and Test sets

Why and when training, validation, and testing splits are needed and how to build them from a tf.data.Dataset using Python

Why and when do we need train, validation, and test splits?

One of the biggest challenges when developing a machine learning model is to prevent it from overfitting to the data set. The difficulty arises when the model learns a combination of weights that performs well on the data used for training but fails to generalize when the model is given images it has never seen. This is known as overfitting.

When implementing a model that will be deployed in the real world, we might want to have an estimate of how it will behave once it is put into production. This is where the test set comes into play, a random partition of the original dataset that is intended to represent data not used for training, so that we can have an estimate of how our model will behave with unseen data.

In addition, there is a third set that is useful when we plan to experiment with different configurations of our model, such as alternative architectures, optimizers, or loss functions, also known as hyperparameter-tuning. To compare the performance of these experiments, another random split can be extracted from the original data set, which is not used for training nor testing but to validate our model in different configurations. This is known as the validation set.

Now, you might be wondering, but then, validation and test sets have the same purpose, right? Well, it is true that both datasets serve to have an estimation of how our model performs on data that have not been used for training. However, when trying different model configurations to have the best validation metrics, we are in a way fitting our model to the validation set, choosing the combination of parameters with the best performance on that set.

Once we have run our hyperparameter-tuning and have the model that performs best, the test set allows us to get an idea of how well this model will perform in production. Therefore, it should only be used at the end of the project.

#metrics #training #machine-learning #data-science #tensorflow