忆依然

文章 评论 浏览 29

忆依然 2025-02-13 09:03:33

您可以尝试更改 dattery =“ [0-9] {5}” to statter =“ x {5}”

我猜测您正在使用的库( inputMask )正在设置 ______ 的默认掩码。 staters =“ [0-9] {5}” 选项允许一系列5位数字,这就是为什么您“在输入掩码中给出数字格式,它可以正常工作”。

rubular 可能是一个有趣的游乐场,可以看到发生了什么。

You could try changing pattern="[0-9]{5}" to pattern="x{5}"

My guess is that the library you're using (inputmask) is setting the default mask of _____. The pattern="[0-9]{5}" option allows a series of 5 digits which is why if you "give number format in input mask, it is working good."

A site like rubular might be a fun playground to see what's going on.

如何在InputMask中使用HTML输入模式添加XXXXX格式?

忆依然 2025-02-12 17:37:03

这听起来像是Next.js布局的好候选人。您将必须撰写布局组件,类似于示例中的 blue ,它接受 color prop prop并将颜色呈现逻辑封装到布局文件。如果没有提供颜色 Prop,则可以实现默认渲染路径。

然后,您可以这样使用:

// pages/whatever.tsx
import type { ReactElement } from 'react'
import Layout from '../components/layout'

export default function Page() {
  return {
    /** Your content */
  }
}

Page.getLayout = function getLayout(page: ReactElement) {
  return (
    <Layout color="blue">
      {page}
    </Layout>
  )
}

https://nextjs.s.org/docs/基本功能/布局#带有typescript

This sounds like a good candidate for Next.js Layouts. You would have to compose a Layout component, similar to Blue in your example, which accepts a color prop and encapsulates the color rendering logic to the layout file. You can implement a default render path if no color prop is provided.

Then you can use it like so:

// pages/whatever.tsx
import type { ReactElement } from 'react'
import Layout from '../components/layout'

export default function Page() {
  return {
    /** Your content */
  }
}

Page.getLayout = function getLayout(page: ReactElement) {
  return (
    <Layout color="blue">
      {page}
    </Layout>
  )
}

https://nextjs.org/docs/basic-features/layouts#with-typescript

next.js默认组件值

忆依然 2025-02-12 01:13:02

用LocalStorage存储的键和值始终为UTF-16字符串格式。与对象一样,整数键和布尔值会自动转换为字符串。

因此,您必须这样打电话:

if(isLoggedIn === 'false'){
    clearInterval(intervalId.current)
}

检查 >。

The keys and the values stored with localStorage are always in the UTF-16 string format. As with objects, integer keys and booleans are automatically converted to strings.

So you have to call like this:

if(isLoggedIn === 'false'){
    clearInterval(intervalId.current)
}

Check the documentation.

停止setInterval函数在useeffect中集

忆依然 2025-02-11 13:18:33

最有可能的原因是您使用的发行版不包括Camunda旋转库。
看:


如果您使用的是Maven,请添加:

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-plugin-spin</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
    </dependency>

Most likely reason is that the distribution you are using does not include the CAMUNDA SPIN libraries.
See:
https://docs.camunda.org/manual/7.17/user-guide/data-formats/
and
https://docs.camunda.org/manual/7.17/user-guide/data-formats/json/

If you are using Maven, add:

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-plugin-spin</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
    </dependency>

Camunda过程无法启动

忆依然 2025-02-11 11:01:09

我修复了它,有几个错误:

主要是:

  • 没有绑定的Vertice缓冲区

工作示例的绘制条:

这里是着色器:

#include <gtk/gtk.h>
#include <epoxy/gl.h>

const char* vertexShaderCode =
"#version 330 core\n"
"layout(location = 0) in vec3 a_position;"
"in vec2 a_tex_pos;"
"out vec2 tex_pos;"
"void main() {"
"  tex_pos = a_tex_pos;"
"  gl_Position = vec4(a_position,1.0);"
"}";

const char* fragmentShaderCode =
"#version 330 core\n"
"uniform sampler2D u_texture;"
"in vec2 tex_pos;"
"layout(location = 0) out vec4 color;"
"void main() {"
"  vec4 texel = texture2D(u_texture, tex_pos);"
"  color = texel;"
"}";

二手变量(类成员):

guint width, height;
guint vao;
guint texture;
guint program;
guint buffers[2];
void* pixels; // image content

某些三角坐标:

GLfloat vertices[12] = {
            -1, -1, 0,
            1, -1, 0,
            -1, 1, 0,
            1, 1, 0
};

GLfloat textureVertices[8] = {
            0, 1,
            1, 1,
            0, 0,
            1, 0
};

init:

glViewport(0, 0, width, height);
glClearColor(1.0f, 1.0f, 1.0f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


// shaders
guint vshader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vshader, 1, &vertexShaderCode, NULL);
glCompileShader(vshader);

guint fshader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fshader, 1, &fragmentShaderCode, NULL);
glCompileShader(fshader);


//program
program = glCreateProgram();
glAttachShader(program, vshader);
glAttachShader(program, fshader);
glLinkProgram(program);

glUseProgram(program);

//glDisable(GL_BLEND);
glDisable(GL_DITHER);
//glDisable(GL_DEPTH_TEST);

glDeleteShader(vshader);
glDeleteShader(fshader);

glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

fbo = 0;
glGenFramebuffers(1, &fbo);

GLuint buffers[2];
glGenBuffers(2, &buffers[0]);

// I swap buffers order

glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(textureVertices), textureVertices, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
glEnableVertexAttribArray(1);

glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
glEnableVertexAttribArray(0);
    
//glBindBuffer(GL_ARRAY_BUFFER, 0); not yet !


int textureHandle = glGetUniformLocation(program, "u_texture");
glUniform1i(textureHandle, 0);
glBindAttribLocation(program, 0, "a_position");
glBindAttribLocation(program, 1, "a_tex_pos");


// textures
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);// OR LINEAR
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

glTexImage2D(
    GL_TEXTURE_2D, 0,
    GL_RGB,
    width, height, 0,
    GL_RGBA,
    GL_UNSIGNED_BYTE, NULL);

    
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // it is effective now

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
GLenum DrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, DrawBuffers);

glBindFramebuffer(GL_FRAMEBUFFER, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0); // unbind now 

glDisableVertexAttribArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindVertexArray(0);

//glDeleteBuffers(2, &buffers[0]); no !

update draudt:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, texture);
// Bind the VAO
glViewport(0, 0, areaWidth, areHeight);

glUseProgram(program);
glBindVertexArray(vao);
glBindTexture(GL_TEXTURE_2D, texture);

glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

// rebind vertices
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

每次所需的数据都复制到像素中请求指针和渲染:

gtk_gl_area_queue_render(GTK_GL_AREA(widget));

I fixed it, there was several mistakes:

mainly:

  • draw strips without an bound vertice buffer

working example:

here are the shaders:

#include <gtk/gtk.h>
#include <epoxy/gl.h>

const char* vertexShaderCode =
"#version 330 core\n"
"layout(location = 0) in vec3 a_position;"
"in vec2 a_tex_pos;"
"out vec2 tex_pos;"
"void main() {"
"  tex_pos = a_tex_pos;"
"  gl_Position = vec4(a_position,1.0);"
"}";

const char* fragmentShaderCode =
"#version 330 core\n"
"uniform sampler2D u_texture;"
"in vec2 tex_pos;"
"layout(location = 0) out vec4 color;"
"void main() {"
"  vec4 texel = texture2D(u_texture, tex_pos);"
"  color = texel;"
"}";

used variables (class members):

guint width, height;
guint vao;
guint texture;
guint program;
guint buffers[2];
void* pixels; // image content

some Triangle coordinates:

GLfloat vertices[12] = {
            -1, -1, 0,
            1, -1, 0,
            -1, 1, 0,
            1, 1, 0
};

GLfloat textureVertices[8] = {
            0, 1,
            1, 1,
            0, 0,
            1, 0
};

Init:

glViewport(0, 0, width, height);
glClearColor(1.0f, 1.0f, 1.0f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


// shaders
guint vshader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vshader, 1, &vertexShaderCode, NULL);
glCompileShader(vshader);

guint fshader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fshader, 1, &fragmentShaderCode, NULL);
glCompileShader(fshader);


//program
program = glCreateProgram();
glAttachShader(program, vshader);
glAttachShader(program, fshader);
glLinkProgram(program);

glUseProgram(program);

//glDisable(GL_BLEND);
glDisable(GL_DITHER);
//glDisable(GL_DEPTH_TEST);

glDeleteShader(vshader);
glDeleteShader(fshader);

glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

fbo = 0;
glGenFramebuffers(1, &fbo);

GLuint buffers[2];
glGenBuffers(2, &buffers[0]);

// I swap buffers order

glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(textureVertices), textureVertices, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
glEnableVertexAttribArray(1);

glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
glEnableVertexAttribArray(0);
    
//glBindBuffer(GL_ARRAY_BUFFER, 0); not yet !


int textureHandle = glGetUniformLocation(program, "u_texture");
glUniform1i(textureHandle, 0);
glBindAttribLocation(program, 0, "a_position");
glBindAttribLocation(program, 1, "a_tex_pos");


// textures
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);// OR LINEAR
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

glTexImage2D(
    GL_TEXTURE_2D, 0,
    GL_RGB,
    width, height, 0,
    GL_RGBA,
    GL_UNSIGNED_BYTE, NULL);

    
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // it is effective now

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
GLenum DrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, DrawBuffers);

glBindFramebuffer(GL_FRAMEBUFFER, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0); // unbind now 

glDisableVertexAttribArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindVertexArray(0);

//glDeleteBuffers(2, &buffers[0]); no !

update drawing:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, texture);
// Bind the VAO
glViewport(0, 0, areaWidth, areHeight);

glUseProgram(program);
glBindVertexArray(vao);
glBindTexture(GL_TEXTURE_2D, texture);

glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

// rebind vertices
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

each time needed data is copied to pixels pointer and rendering is requested:

gtk_gl_area_queue_render(GTK_GL_AREA(widget));

使用openGL纹理显示RGB图像

忆依然 2025-02-11 09:48:05

Pytest在多个测试中没有检查参数是否相同,每个测试都是独立的。 scope =“ session” 仅在 fixture 未明确调用时才相关,您正在执行此操作,因此每个测试中的每个参数都会调用 device> device> device> device> device> /代码> fixture

您可以在 conftest.py 中实现一个简单的逻辑,以在多个测试中使用同一服务器实例

servers = {}

@pytest.fixture
def deviceundertest(request):
    server = request.param
    if server not in servers:
        servers[server] = Server() # create your server instance
    return servers[server]

Pytest doesn't check if the arguments are the same in multiple tests, every test is independent. The scope="session" is relevant only if the fixture is not invoked explicitly, which you are doing, so every parameter in each test will invoke the deviceundertest fixture.

You can implement a simple logic in conftest.py to use the same server instance in multiple tests

servers = {}

@pytest.fixture
def deviceundertest(request):
    server = request.param
    if server not in servers:
        servers[server] = Server() # create your server instance
    return servers[server]

固定装置间接的Pytest范围范围问题

忆依然 2025-02-11 07:00:17

请注意,10_000_000的字符(16位)将花费约20 MB。 If you will take a look at the decompilation您会注意到, Yeild返回在内部&lt; iterator&gt; 中生成的类中生成的类,该类又具有当前字段来存储字符串(到实现 iEnumerator&lt; string&gt; .current ):

[CompilerGenerated]
private sealed class <Iterator>d__2 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable
{
​    ...
    private string <>2__current;
    ...
}

iterator 内部将汇编到类似的东西:

[IteratorStateMachine(typeof(<Iterator>d__2))]
private IEnumerable<string> Iterator()
{
    return new <Iterator>d__2(-2);
}

这会导致当前字符串始终存储在内存中的内存中_enumerable.getEnumerator(); 实现(迭代启动之后)时, dnagenerator 实例不是本身。

upd

我的理解是,一个ienumerable可以创建许多ienumerator。 afaik这两个接口并不意味着有一对一的关系。

是的,如果生成收益率返回枚举可以创建多个枚举者,但是在这种特殊情况下,实现具有“一对一”关系,因为生成的实现都是 iEnumerable < /code>和 ienumerator

private sealed class <Iterator>d__2 : 
    IEnumerable<string>, IEnumerable,
    IEnumerator<string>, IEnumerator, 
    IDisposable

,但我不喜欢每次需要枚举时创建一个新的枚举。

但这实际上是当您调用 _enumerable.getEnumerator()(显然是实现细节)时,实际上正在发生的事情,如果您检查已经提到的解说,您会看到 _enumosert = iterator()< /code>实际上是 new&lt; iterator&gt; d__2(-2) and &lt; iterator&gt; d_.getEnumerator()看起来像这样:

IEnumerator<string> IEnumerable<string>.GetEnumerator()
{
    if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
    {
        <>1__state = 0;
        return this;
    }
    return new <Iterator>d__2(0);
}

因此它应该创建一个除第一个枚举外,每次新迭代器实例,因此您的 public ienumerator&lt; string&gt; getEnumerator()=&gt; iterator()。getEnumerator(); 方法很好。

Note that 10_000_000 of chars (which are 16 bit) will take approximately 20 MB. If you will take a look at the decompilation you will notice that yeild return results in internal <Iterator> class generated which in turn has a current field to store the string (to implement IEnumerator<string>.Current):

[CompilerGenerated]
private sealed class <Iterator>d__2 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable
{
​    ...
    private string <>2__current;
    ...
}

And Iterator method internally will be compiled to something like this:

[IteratorStateMachine(typeof(<Iterator>d__2))]
private IEnumerable<string> Iterator()
{
    return new <Iterator>d__2(-2);
}

Which leads to the current string always being stored in memory for _enumerable.GetEnumerator(); implementation (after iteration start) while DnaGenerator instance is not GCed itself.

UPD

My understanding is that a single IEnumerable can create many IEnumerators. AFAIK these two interfaces are not meant to have an one-to-one relationship.

Yes, in case of generated for yield return enumerable it can create multiple enumerators, but in this particular case the implementation have "one-to-one" relationship because the generated implementation is both IEnumerable and IEnumerator:

private sealed class <Iterator>d__2 : 
    IEnumerable<string>, IEnumerable,
    IEnumerator<string>, IEnumerator, 
    IDisposable

But I am not a fan of creating a new enumerable each time an enumerator is needed.

But it is actually what is happening when you call _enumerable.GetEnumerator() (which is obviously an implementation detail), if you check already mentioned decompilation you will see that _enumerable = Iterator() is actually new <Iterator>d__2(-2) and <Iterator>d__2.GetEnumerator() looks something like this:

IEnumerator<string> IEnumerable<string>.GetEnumerator()
{
    if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
    {
        <>1__state = 0;
        return this;
    }
    return new <Iterator>d__2(0);
}

So it actually should create a new iterator instance every time except the first enumeration, so your public IEnumerator<string> GetEnumerator() => Iterator().GetEnumerator(); approach is just fine.

由C#迭代器泄漏的托管内存

忆依然 2025-02-11 05:29:06

它需要一些时间来从您的需求中构建网络,但是我提供了一些样本来创建客户层或模型,您从嵌入式层开始,突然之间,随机数据叶子每次GRU和LSTM学习层都会产生不同的输入当它们具有:

  1. 匹配输入和目标层和参数时。
  2. 学习范围何时可以区分输入,重复封闭电流,而在数据模式为模式时,则专门使用LSTM
    重要的是图片或继续数据。
  3. 线性和Sigmoid在基于分布值进行比较时需要的某个时候提供了差异和软磁性。这
    应该创建对比度输出,除了应用于softmax
    值的权重。
  4. 损耗FN基于相似的输出维度/期望

[示例]:

class create_emb_layer( tf.keras.layers.Embedding ):
    def __init__( self, weights_matrix, bidirectional=True ):
        self.num_embeddings = weights_matrix[0]
        self.embeddings_size = weights_matrix[1]
        self.bidirectional = bidirectional
        super(create_emb_layer, self).__init__( self.embeddings_size, self.num_embeddings )

    def build(self, input_shape):
        self.kernel = self.add_weight("kernel",
        shape=[int(input_shape[-1]),
        self.input_dim])

    def call(self, inputs):
        return tf.matmul(inputs, self.kernel)

[我的模型]:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Model Initialize
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
model = tf.keras.models.Sequential([
    tf.keras.layers.InputLayer(input_shape=( 32, 32, 4 )),
    tf.keras.layers.Normalization(mean=3., variance=2.),
    tf.keras.layers.Normalization(mean=4., variance=6.),
    tf.keras.layers.Conv2D(32, (3, 3), activation='relu'),
    tf.keras.layers.MaxPooling2D((2, 2)),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Reshape((128, 225)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(96, return_sequences=True, return_state=False)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(96)),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(192, activation='relu'),
    tf.keras.layers.Dense(10),
])

[output] [output]:

It required some time to build networks from your requirements but I provided a few samples to create a customer layer or model, you start from an embedded layer and suddenly random leaves of data create different input every time GRU and LSTM learning layers may provide good results when they had :

  1. Matching input and target layer and parameters.
  2. Learning scopes when they can differentiate input, repeating of gated current, and LSTM is specifically used when patterns of data are
    significant such as pictures or continue data.
  3. Linear, and Sigmoid provide contrast differentiate and softmax sometime we required when compared based on distribution values. This
    is supposed to create contrast output excepted softmax applied on
    weights of values.
  4. Loss Fn is based on a similar output dimension/expectation

[ Sample ]:

class create_emb_layer( tf.keras.layers.Embedding ):
    def __init__( self, weights_matrix, bidirectional=True ):
        self.num_embeddings = weights_matrix[0]
        self.embeddings_size = weights_matrix[1]
        self.bidirectional = bidirectional
        super(create_emb_layer, self).__init__( self.embeddings_size, self.num_embeddings )

    def build(self, input_shape):
        self.kernel = self.add_weight("kernel",
        shape=[int(input_shape[-1]),
        self.input_dim])

    def call(self, inputs):
        return tf.matmul(inputs, self.kernel)

[ My model ]:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Model Initialize
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
model = tf.keras.models.Sequential([
    tf.keras.layers.InputLayer(input_shape=( 32, 32, 4 )),
    tf.keras.layers.Normalization(mean=3., variance=2.),
    tf.keras.layers.Normalization(mean=4., variance=6.),
    tf.keras.layers.Conv2D(32, (3, 3), activation='relu'),
    tf.keras.layers.MaxPooling2D((2, 2)),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Reshape((128, 225)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(96, return_sequences=True, return_state=False)),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(96)),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(192, activation='relu'),
    tf.keras.layers.Dense(10),
])

[ Output ]:

Sample

我与注意模型的RNN始终可以预测同一类,即使我的数据没有不平衡

忆依然 2025-02-10 04:58:34

一个选项是将覆盖与两个栅栏使用。在这里,我首先使用 Volcano 数据集创建两个示例抹布。然后,我将 na s随机分配到第一个栅格( rst1 )。然后,将覆盖应用于 rst2 中的单元格为 na s na s < na 单元格中的细胞代码> rst1 。

library(raster)

rst <- raster::raster(volcano)
rst1 <- rst
rst2 <- rst

# Assign some random cells NAs in rst1.
set.seed(123)
id <- sample(1:ncell(rst), 1000)
rst1[id] <- NA

# Assign NA to the cells where NA is present in rast1.
rst2_mod <- overlay(
  rst2,
  rst1,
  fun = function(x, y) {
    x[is.na(y[])] <- NA
    return(x)
  }
)

plot(rst2_mod)

output

​多于)。我们可以堆叠两个栅格层,然后将单元格更改为 na 如果该单元格存在任何 Na

s.new <-
  raster::calc(
    raster::stack(rst2, rst1),
    fun = function(x)
      if (sum(is.na(x)) > 0)
        x * NA
    else
      x
  )

plot(s.new)

One option is to use overlay with the two rasters. Here, I first create two sample rasters using the volcano dataset. Then, I randomly assign NAs to the first raster (rst1). Then, apply overlay to change the cells in rst2 to NAs for those that match the NA cells in rst1.

library(raster)

rst <- raster::raster(volcano)
rst1 <- rst
rst2 <- rst

# Assign some random cells NAs in rst1.
set.seed(123)
id <- sample(1:ncell(rst), 1000)
rst1[id] <- NA

# Assign NA to the cells where NA is present in rast1.
rst2_mod <- overlay(
  rst2,
  rst1,
  fun = function(x, y) {
    x[is.na(y[])] <- NA
    return(x)
  }
)

plot(rst2_mod)

Output

enter image description here

Another option is to just use calc (using rst1 and rst2 from above). We can stack the two raster layers, then change the cell to NA if there are any NAs present for that cell.

s.new <-
  raster::calc(
    raster::stack(rst2, rst1),
    fun = function(x)
      if (sum(is.na(x)) > 0)
        x * NA
    else
      x
  )

plot(s.new)

enter image description here

用另一个光栅掩盖栅格

忆依然 2025-02-09 21:34:46

算术是基本10,因此小数代表十分之一,百分之十。

正常 积分存储为整数mantissas和指数。 Mantissa代表着重要的数字。指数就像科学符号一样,但它使用2的碱基而不是10。例如,64.0将以1的mantissa表示,指数为6。0.125将以1的Mantissa为1,指数为-3。

浮点小数必须将负2

0.1b = 0.5d
0.01b = 0.25d
0.001b = 0.125d
0.0001b = 0.0625d
0.00001b = 0.03125d

等负功率添加。

在处理浮点算术时,通常使用错误的delta而不是使用平等运算符。而不是

if(a==b) ...

你会使用

delta = 0.0001; // or some arbitrarily small amount
if(a - b > -delta && a - b < delta) ...

Normal arithmetic is base-10, so decimals represent tenths, hundredths, etc. When you try to represent a floating-point number in binary base-2 arithmetic, you are dealing with halves, fourths, eighths, etc.

In the hardware, floating points are stored as integer mantissas and exponents. Mantissa represents the significant digits. Exponent is like scientific notation but it uses a base of 2 instead of 10. For example 64.0 would be represented with a mantissa of 1 and exponent of 6. 0.125 would be represented with a mantissa of 1 and an exponent of -3.

Floating point decimals have to add up negative powers of 2

0.1b = 0.5d
0.01b = 0.25d
0.001b = 0.125d
0.0001b = 0.0625d
0.00001b = 0.03125d

and so on.

It is common to use a error delta instead of using equality operators when dealing with floating point arithmetic. Instead of

if(a==b) ...

you would use

delta = 0.0001; // or some arbitrarily small amount
if(a - b > -delta && a - b < delta) ...

浮点数学破裂了吗?

忆依然 2025-02-09 02:51:19

事实证明,Android 12要求每个活动都具有清单中的“导出”标签。我将这些设置为false,因为我一开始不知道这是什么意思,但是将其更改为true使Bixby密钥能够再次启动我的应用程序

It turns out that android 12 required each activity to have the "exported" tag set in the manifest. I set those to false because i didnt know what it meant at first, but changing it to true has made the bixby key able to launch my app again

Bixby Key的Launcing应用程序的Android 12先决条件?

忆依然 2025-02-07 10:51:57

请按快捷键键:

  • 窗口: shift + o
  • mac: cmd> cmd + y y

Please press the shortcut key:

  • Window: Shift+O
  • Mac: Cmd+Y

我所有的figma工作都变成了黑色大纲

忆依然 2025-02-07 09:50:34

您可以使用经典循环:

import re

out = []
flag = False
for item in sth_list:
    if item.startswith('end:'):
        flag = False
    if flag:
        if item:
            out[-1] += ' '+item
    else:
        out.append(item)
    if item == 'start:':
        flag = True

输出:

['name: michael',
 'age:56',
 'start: something is happening',
 'end:',
 'anything could be here:',
 'some other things:',
 'more things:']

You can use a classical loop:

import re

out = []
flag = False
for item in sth_list:
    if item.startswith('end:'):
        flag = False
    if flag:
        if item:
            out[-1] += ' '+item
    else:
        out.append(item)
    if item == 'start:':
        flag = True

output:

['name: michael',
 'age:56',
 'start: something is happening',
 'end:',
 'anything could be here:',
 'some other things:',
 'more things:']

加入列表中两个元素之间的列表元素

忆依然 2025-02-07 04:00:44

好的,我发现了我的问题。首先,一切都起作用了,但是IDE一直抱怨丢失类型,直到我安装了 types type-protobuf 软件包。

OK, I found out my problem. Everything worked in the first place, but IDE had been complaining about missing types until I installed the types-protobuf package.

Python Protobuf 3.20.1缺少任何,空和其他类型

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文