Category Archives: How to Fix

Keras:KeyError:‘Failed to format this callback filepath:{val_loss:.4f}.h5. Reason: \‘val_loss\‘‘

If you use keras’s imagedatagenerator for image enhancement, it is as follows:

validataion_generator = validation_datagen.flow_from_directory(validation_dir,
                                                               target_size=target_size,
                                                               batch_size=batch_size,
                                                               class_mode='categorical',
                                                               subset="validation")

In addition, your training set and verification set are two different folders, and the file name of the saved model is required to include the loss of the model above the verification set, then the error described in the title is likely to occur:

Keras:KeyError:'Failed to format this callback filepath:{val_loss:.4f}.h5. Reason: \'val_loss\''

At this time, you only need to delete the subset parameter. The subset parameter is generally used for training and verification. It is a batch of data and has been passed into validation_ Subset needs to be defined only when split is used for data division. The specific modifications are as follows:

validataion_generator = validation_datagen.flow_from_directory(validation_dir,
                                                               target_size=target_size,
                                                               batch_size=batch_size,
                                                               class_mode='categorical')

Re run the program, there will be no error, normal training!

Solution to the expiration and unavailability of Android studio plug-in plugin

Gsonformat: plugins official website

GsonFormat : github

We use the import prompt to download expired.

solve

Download the source code to idea:

Modify the following two points:

1、gradle-wrapper.properties

Change the version to the one on your computer:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip

2、build.gradle

Change the version to the one on your computer:

1. Org.jetbrains.intellij version: after creating gradle project, you can view:

2. Intellij.version can be viewed through idea about:

be careful:

The key value pair key = valueplugins in the IntelliJ tag is an array

The final document is as follows:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
        maven {
            url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
        }
    }
}
plugins {
    id 'org.jetbrains.intellij' version '1.1.4'
}

apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
// dependencies {
//     compile project(':ThirdPart:checktreetable')
//     compile project(':ThirdPart:json')
// }
sourceSets {
    main {
        java {
            srcDir "${project.rootDir.absolutePath}/ThirdParty/json/java/src"
            srcDir "${project.rootDir.absolutePath}/ThirdParty/treetable/java/src"
        }

    }
}

//IntelliJ IDEA 2021.2 (Community Edition)
//Build #IC-212.4746.92, built on July 27, 2021
//Runtime version: 11.0.11+9-b1504.13 x86_64
//VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
//macOS 11.1
//GC: G1 Young Generation, G1 Old Generation
//Memory: 1024M
//Cores: 8
//Non-Bundled Plugins: GsonFormatPlus (1.6.1), com.godwin.json.parser (1.4.2), cn.yiiguxing.plugin.translate (2.9.2)
//Kotlin: 212-1.5.10-release-IJ4746.92

intellij {
    plugins = ['java']
    version = 'IC-212.4746.92'
    pluginName = 'GsonFormat'
    updateSinceUntilBuild = false

//    publish {
//        pluginId '7910'
//        username publishUsername
//        password publishPassword
//    }

//     Uncomment to test against Android Studio
//     intellij.alternativeIdePath = '/Applications/Android Studio.app'
}

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    maven {
        url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
    }
    maven { url "https://www.jetbrains.com/intellij-repository/releases" }
    maven { url "https://www.jetbrains.com/intellij-repository/snapshots" }
}

Repackage:

The generated file is in:

The generated plug-in can be imported into the zip package locally.

Zip file

It has been uploaded here

[Elasticsearch] es 7.12 Root mapping definition has unsupported parameters: _all

1. Scenario 1

1.1 general

An environment was upgraded from ES 6.8 to es 7.12, and then I executed a rollover API and found that an error could not be reported successfully.

Root mapping definition has unsupported parameters: _ all

Finally, I checked the template and found that the old template has_ All field, just remove this. This is not supported in the new version

Caused by: java.lang.IllegalStateException: Ambiguou There is already ‘XXXXXXController‘ bean method

**

Errors are reported as follows:

**
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘com.offcn.seckill.feign.SeckillGoodsFeignn’ method
com.offcn.seckill.feign.SeckillGoodsFeignn#findPage(SeckillGoods, int, Int)
to {post/seckillgoods/search/{page}/{size}}: there is already ‘seckillgoodscontroller’ bean method
reason : there are two or more requestmapping or getmapping with the same name
solution:
1. Check whether there are the same requestmapping URLs in all other classes, If you modify different URLs, you can
2. In the remote calling interface using feign, the requestmapping on the interface is the same as the requestmapping URL of the called class. For problems, you can configure the requestmpping URL of the interface into the method of this interface, Remove the URL configuration of interface requestmapping
for example:
and replace it with the following:
if your problem is solved, please click praise and comment to support the blogger’s hard work =

ModuleNotFoundError: No module named ‘tensorflow_core.estimator‘

Question

When using tensorflow, an error is reported: modulenotfounderror: no module named ‘tensorflow_ core.estimator’

Possible causes and corresponding solutions

1、

Problem: the Matplotlib library was not imported
solution: Import matplotlib.pyplot as plot
if the Matplotlib library is not installed, use the command CONDA install Matplotlib in the command client to install the Matplotlib library.

2、

Problem: the version of tensorflow is inconsistent with that of tensorflow estimator,
solution: check whether the current tensorflow version is consistent with that of tensorflow estimator by using the command CONDA list in the command client. If not, reduce or increase the version of one party.

How to Use Truffle to Deploy contracts on moonbeam

Error: Error: Expected parameter 'from' not passed to function.

EVM/moonbeam_doc/Using with Truffle/TruffleTest/MetaCoin$ truffle migrate

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Error: Expected parameter 'from' not passed to function.
    at has (/usr/local/lib/node_modules/truffle/build/webpack:/packages/expect/dist/src/index.js:10:1)
    at Object.options (/usr/local/lib/node_modules/truffle/build/webpack:/packages/expect/dist/src/index.js:19:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:65:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)
Truffle v5.4.3 (core: 5.4.3)
Node v14.15.5

Solution:
add the: from parameter in trufle-config.js to indicate which account is in the deployment contract
before adding:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 9933,
      network_id: "*",     

    }
  }        

};

After adding:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 9933,
      network_id: "*",
      from: "0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b",

    }
  }        

};

0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b It’s the node’s built-in ethereum account.
Deploy again: truffle migrate, error reported:no signer available.

EVM/moonbeam_doc/Using with Truffle/TruffleTest/MetaCoin$ truffle migrate

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'development'
> Network id:      1281
> Block gas limit: 15000000 (0xe4e1c0)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- Returned error: no signer available.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)
Truffle v5.4.3 (core: 5.4.3)
Node v14.15.5

View account
enter the truss console first:

truffle console

Default account:

The truss migrate command runs the migration footprint deployment contract.

Which account is used when executing truss migrate
web3.eth.defaultaccount – default account

The web3.eth.defaultaccount attribute records the default address. If the from attribute is not specified in the following method, the value of the web3.eth.defaultaccount attribute will be used as the default from attribute value.

web3.eth.sendTransaction()web3.eth.call()new web3.eth.Contract() -> myContract.methods.myMethod().call()new web3.eth.Contract() -> myContract.methods.myMethod().send()

Call:

web3.eth.defaultAccount

Attribute:
string – 20 bytes: Ethereum address. You should save the private key of the address in the node or keystore. The default value is undefined

Example code:

web3.eth.defaultAccount;
> undefined

// set the default account
web3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe';

Ganache cli has 10 preset accounts, and truss migrate uses the first preset account for deployment contracts by default.

truss migrate What did you do

///truffle/packages/core/lib/commands/deploy.js

const migrate = require("./migrate");

const command = {
  command: "deploy",
  description: "(alias for migrate)",
  builder: migrate.builder,
  help: {
    usage:
      "truffle deploy [--reset] [-f <number>] [--compile-all] [--verbose-rpc]",
    options: migrate.help.options,
    allowedGlobalOptions: ["network", "config"]
  },
  run: migrate.run
};

module.exports = command;

Call the deploy() function:

//truffle/packages/contract/lib/execute.js

  /**
   * Deploys an instance
   * @param  {Object} constructorABI  Constructor ABI segment w/ inputs & outputs keys
   * @return {PromiEvent}             Resolves a TruffleContract instance
   */
  deploy: function (constructorABI) {
    const constructor = this;
    const web3 = constructor.web3;

    return function () {
      let deferred;
      const promiEvent = new PromiEvent(false, constructor.debugger, true);

      execute
        .prepareCall(constructor, constructorABI, arguments)
        .then(async ({ args, params, network }) => {
          const { blockLimit } = network;

          utils.checkLibraries.apply(constructor);

          // Promievent and flag that allows instance to resolve (rather than just receipt)
          const context = {
            contract: constructor,
            promiEvent,
            onlyEmitReceipt: true
          };

          const options = {
            data: constructor.binary,
            arguments: args
          };

          const contract = new web3.eth.Contract(constructor.abi);
          params.data = contract.deploy(options).encodeABI();

          params.gas = await execute.getGasEstimate.call(
            constructor,
            params,
            blockLimit
          );

          context.params = params;

          promiEvent.eventEmitter.emit("execute:deploy:method", {
            args,
            abi: constructorABI,
            contract: constructor
          });
		  
          deferred = execute.sendTransaction(web3, params, promiEvent, context); //the crazy things we do for stacktracing...

          try {
            const receipt = await deferred;
            if (receipt.status !== undefined && !receipt.status) {
              const reason = await Reason.get(params, web3);

              const error = new StatusError(
                params,
                context.transactionHash,
                receipt,
                reason
              );

              return context.promiEvent.reject(error);
            }

            const web3Instance = new web3.eth.Contract(
              constructor.abi,
              receipt.contractAddress
            );
            web3Instance.transactionHash = context.transactionHash;

            context.promiEvent.resolve(new constructor(web3Instance));
          } catch (web3Error) {
            // Manage web3's 50 blocks' timeout error.
            // Web3's own subscriptions go dead here.
            await override.start.call(constructor, context, web3Error);
          }
        })
        .catch(promiEvent.reject);

      return promiEvent.eventEmitter;
    };
  },

Preparecall() function:

  /**
   * Prepares simple wrapped calls by checking network and organizing the method inputs into
   * objects web3 can consume.
   * @param  {Object} constructor   TruffleContract constructor
   * @param  {Object} methodABI     Function ABI segment w/ inputs & outputs keys.
   * @param  {Array}  _arguments    Arguments passed to method invocation
   * @return {Promise}              Resolves object w/ tx params disambiguated from arguments
   */
  prepareCall: async function (constructor, methodABI, _arguments) {
    let args = Array.prototype.slice.call(_arguments);
    let params = utils.getTxParams.call(constructor, methodABI, args);

    args = utils.convertToEthersBN(args);

    if (constructor.ens && constructor.ens.enabled) {
      const { web3 } = constructor;
      const processedValues = await utils.ens.convertENSNames({
        networkId: constructor.network_id,
        ensSettings: constructor.ens,
        inputArgs: args,
        inputParams: params,
        methodABI,
        web3
      });
      args = processedValues.args;
      params = processedValues.params;
    }

    const network = await constructor.detectNetwork();
    return { args, params, network };
  },

Sendtransaction() function

  //our own custom sendTransaction function, made to mimic web3's,
  //while also being able to do things, like, say, store the transaction
  //hash even in case of failure.  it's not as powerful in some ways,
  //as it just returns an ordinary Promise rather than web3's PromiEvent,
  //but it's more suited to our purposes (we're not using that PromiEvent
  //functionality here anyway)
  //input works the same as input to web3.sendTransaction
  //(well, OK, it's lacking some things there too, but again, good enough
  //for our purposes)
  sendTransaction: async function (web3, params, promiEvent, context) {
    //if we don't need the debugger, let's not risk any errors on our part,
    //and just have web3 do everything
    if (!promiEvent || !promiEvent.debug) {
      const deferred = web3.eth.sendTransaction(params);
      handlers.setup(deferred, context);
      return deferred;
    }
    //otherwise, do things manually!
    //(and skip the PromiEvent stuff :-/ )
    return sendTransactionManual(web3, params, promiEvent);
  }

Compare and analyze how the deployment script deploy.js calls the web3.js interface to deploy a contract:

//filename: deploy.js

const Web3 = require('web3');
const contractFile = require('./compile');

/*
   -- Define Provider & Variables --
*/
// Provider
const providerRPC = {
   development: 'http://localhost:8545',
};
const web3 = new Web3(providerRPC.development); //Change to correct network

// Variables
const account_from = {
   privateKey: 'YOUR-PRIVATE-KEY-HERE',
   address: 'PUBLIC-ADDRESS-OF-PK-HERE',
};
const bytecode = contractFile.evm.bytecode.object;
const abi = contractFile.abi;

/*
   -- Deploy Contract --
*/
const deploy = async () => {
   console.log(`Attempting to deploy from account ${account_from.address}`);

   // Create Contract Instance
   const incrementer = new web3.eth.Contract(abi);

   // Create Constructor Tx
   const incrementerTx = incrementer.deploy({
      data: bytecode,
      arguments: [5],
   });

   // Sign Transacation and Send
   const createTransaction = await web3.eth.accounts.signTransaction(
      {
         data: incrementerTx.encodeABI(),
         gas: await incrementerTx.estimateGas(),
      },
      account_from.privateKey
   );

   // Send Tx and Wait for Receipt
   const createReceipt = await web3.eth.sendSignedTransaction(
      createTransaction.rawTransaction
   );
   console.log(
      `Contract deployed at address: ${createReceipt.contractAddress}`
   );
};

deploy();

Will the slave account be involved in calling the RPC interface of Ethereum to initiate a deployment contract

What does moonbeam’s truss box do to make it compatible with truss migrate

Related contents:
https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts

Truffle/NPM error “expected parameter ‘from’ not passed to function”
truffle practice
Default truffle project gives’ expected parameter ‘from’ not passed to function. ‘error after’ truffle migrate ‘command #548

Explain truffle migrations in detail – contract deployment is no longer confused
Ethereum development learning notes – truffle migrate

Node Error: Too many hive partitions report an error [How to Solve]

Fatal error occurred when node tried to create too many dynamic partitions. The maximum number of dynamic partitions is controlled by hive.exec.max.dynamic.partitions and hive.exec.max.dynamic.partitions.pernode. Maximum was set to 100 partitions per node, number of dynamic partitions on this node: 105

 

Solution:

hive.exec.max.dynamic.partitions=500
hive.exec.max.dynamic.partitions.pernode=500

Solve the error of Chinese file uploaded by springboot

Springboot version: 2.3.0.release

Front end use   File upload with unityengine.wwwform

Service error:

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.NoClassDefFoundError: javax/mail/internet/MimeUtility

Positioning questions:

POM file import dependency

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>

Re run and solve the problem (* ^ ▽ ^ *)~~

Resolve Vue error empty block XXXX

1. Reason for error reporting
under the strict syntax mode of Vue, empty code blocks are not allowed. For example, if (true) {
} how can Vue report this error when the if condition is true
2. The solution is to modify the code logic by itself. The specific modification should be determined according to the specific code, as long as it is ensured that there are no empty code blocks